Did some browsing of the tutorial and wanted to try out some stuff in the REPL
» f = \n -> n * 2
── MISSING FINAL EXPRESSION ────────────────────────────────────────────────────
I am partway through parsing a definition, but I got stuck here:
1│ app "app" provides [replOutput] to "./platform"
2│
3│ replOutput =
4│ f = \n -> n * 2
^
This definition is missing a final expression. A nested definition
must be followed by either another definition, or an expression
x = 4
y = 2
x + y
I got this, so I thought maybe I was doing something wrong so I directly copied the example from the tutorial for defining funcitons.
» addAndStringify = \num1, num2 ->
… Num.toStr (num1 + num2)
── MISSING FINAL EXPRESSION ────────────────────────────────────────────────────
I am partway through parsing a definition, but I got stuck here:
1│ app "app" provides [replOutput] to "./platform"
2│
3│ replOutput =
4│ addAndStringify = \num1, num2 ->
5│ Num.toStr (num1 + num2)
^
This definition is missing a final expression. A nested definition
must be followed by either another definition, or an expression
x = 4
y = 2
x + y
Am I messing something up or is this a bug?
To be clear: this is in the online WASM repl at https://www.roc-lang.org/repl
The web repl currently has limitations
It basically has no memory
So you can save a value for lster
So you have to define the function and then use it to returns a result
_Oh_ you can't do _any_ variable assignment I see
I mean you can, but you have to use it immediately in the web repl currently cause it has no history
f = \x -> x + 1
f 2
That should work
Note: just an issue with the web repl. Should work as expected in CLI repl
I've created #5603 to inform users about this difference in features.
Last updated: Jul 06 2025 at 12:14 UTC