-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing comments before module headers #1135
Comments
For this Example.roc program: #!/usr/bin/env roc
# comment abc
# comment cde
app "helloWorld"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" }
imports [pf.Stdout]
provides [main] to pf
main =
Stdout.line "Hello, World!" making it executable and running with ./Example.roc works (Ubuntu 22). (However roc run doesn't work: Perhaps this bug can be declared as solved and the issue closed? @Anton-4 ? |
No longer reproducible. Tested using #!/usr/bin/env roc
# Some comment
app ""
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.8.1/x8URkvfyi9I0QhmVG98roKBUs_AZRkLFwFJVJ3942YA.tar.br",
}
imports [pf.Stdout]
provides [main] to pf
main = Stdout.line "Hi"
|
I think the compiler has regressed on this. I'm using Roc built with Nix from b8d9367. Taking Luke's example above verbatim: #!/usr/bin/env roc
# Some comment
app ""
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.8.1/x8URkvfyi9I0QhmVG98roKBUs_AZRkLFwFJVJ3942YA.tar.br",
}
imports [pf.Stdout]
provides [main] to pf
main = Stdout.line "Hi" Things work fine:
But formatting the file changes it to a new syntax: # !/usr/bin/env roc
# Some comment
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.8.1/x8URkvfyi9I0QhmVG98roKBUs_AZRkLFwFJVJ3942YA.tar.br",
}
import pf.Stdout
main = Stdout.line "Hi" And running that doesn't work:
It seems the reason is because the formatter adds a space after the first |
Fixes the regression I described in [roc-lang#1135]. [roc-lang#1135]: roc-lang#1135
Currently, the parser fails when trying to parse a module that has a comment before its module header.
This is unfortunate because if it worked, we could have "roc scripts" on UNIX systems as easily as making this the first line in the module:
...and then marking
Example.roc
executable. I verified that this technique works, except that whenever you executeExample.roc
, it immediately crashes with a parse error. 😄The text was updated successfully, but these errors were encountered: