I am walking through the Roc tutorial, and got to the introduction of the as
keyword. However I get the following compiler error when I run:
── MISSING ARROW ─────────────────────────────────────────────────── Hello.roc ─
I am partway through parsing a function argument list, but I got stuck
here:
10│ addAndStringify = \{ iguanas: lizards } as counts ->
^
I was expecting a -> next.
My code is verbatim what is shown in the tutorial (Lines 383-384):
addAndStringify = \{ iguanas: lizards } as counts ->
Num.toStr (counts.birds + lizards)
Any ideas what might be going on here?
NOTE: I am on commit 35de4c6 - latest from main at time of writing
Looking across current Roc code and poking around a bit, I think that as
is currently only available in a limited scope.
It seems that it works in type definitions where it is used for some platform related type naming, but I don't see any variable naming use cases.
Would you mind filing a bug for this?
Then someone with more context on this feature can take a proper look.
I guess for now, we are stuck with destructuring:
addAndStringify = \counts ->
{ iguanas: lizards } = counts
Num.toStr (counts.birds + lizards)
Brendan Hansknecht Thanks so much for the response! I can definitely file an issue for this. On a side note, I'm still working on comprehending the codebase. Would you mind pointing me toward which files you were looking at to find the behavior of the as
keyword?
Okay, per your recommendation, I've opened an issue for this here
In this case, I didn't feel like actually digging into the parser or anything complex. Instead I:
as
in .roc
files.Last updated: Jul 26 2025 at 12:14 UTC