You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the user defines a JS extern with control effects like so:
extern control def foo(): Int =
js """
$effekt.pure(2)
"""
Then the call fails at runtime with an error like:
foo_2839().then((v_r_2852_3977) =>
^
TypeError: Cannot read properties of undefined (reading 'then')
at Object.head (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs.js:828:15)
at apply (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs.js:459:25)
at Object.apply (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs.js:549:34)
at trampoline (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs.js:435:19)
at Object.run (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs.js:542:18)
at Object.main (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs.js:836:27)
at Object.<anonymous> (/Users/gaisseml/dev/effekt/experiments/out/js_multiline_externs:2:79)
at Module._compile (node:internal/modules/cjs/loader:1480:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Module.load (node:internal/modules/cjs/loader:1287:32)
Node.js v22.1.0
[error] Process exited with non-zero exit code 1.
Expected behaviour
This should return 2.
Why does this happen
The above definition gets translated to the following JS:
functionfoo_2839(){return$effekt.pure(2);}
Semicolon insertion will insert a ; after the return, so this is equivalent to something like:
functionfoo_2839(){returnundefined;// early return$effekt.pure(2);// dead code;}
Full example code
extern control def foo(): Int =
js """
$effekt.pure(2)
"""
extern control def bar(): Int =
js """$effekt.pure(1)"""
def main() = {
println(bar())
println(foo())
}
The text was updated successfully, but these errors were encountered:
When the user defines a JS extern with control effects like so:
Then the call fails at runtime with an error like:
Expected behaviour
This should return 2.
Why does this happen
The above definition gets translated to the following JS:
Semicolon insertion will insert a
;
after the return, so this is equivalent to something like:Full example code
The text was updated successfully, but these errors were encountered: