roc
roc copied to clipboard
Comment between type annotation and declaration results in compiler seeing 2 declarations
Any comment added between a type annotation and the associated declaration results in the compiler thinking the two are separate declarations.
Reproduction In any of the "Hello world" examples, write:
main: Str
# comment
main = "I'm still the same declaration!"
Expected behavior
The program runs fine and prints I'm still the same declaration!
Actual behavior I get the following error:
emitted runtime error NoImplementationNamed { def_symbol: `8.IdentId(0)` }
🔨 Rebuilding host...
── DUPLICATE NAME ──────────────────────────────────────────────────────────────
The main name is first defined here:
6│ main: Str
^^^^
But then it's defined a second time here:
8│ main = "Hello!"
^^^^
Since these variables have the same name, it's easy to use the wrong
one on accident. Give one of them a new name.
────────────────────────────────────────────────────────────────────────────────
Done!
Roc hit a panic: NoImplementationNamed { def_symbol: `8.IdentId(0)` }
The compiler is interpreting this as intended, but we could definitely give a helpful tip in this situation!
I get the same runtime error if the definition is omitted altogether. I was surprised when it compiled. Usually that would give me a link-time error in C for example.
Example:
app "helloweb"
packages { pf: "https://github.com/roc-lang/basic-webserver/releases/download/0.3.0/gJOTXTeR3CD4zCbRqK7olo4edxQvW5u3xGL-8SSxDcY.tar.br" }
imports [
pf.Task.{ Task },
pf.Http.{ Request, Response },
]
provides [main] to pf
main : Request -> Task Response []