Skip to content
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

Source code does not show for crystal eval compilation errors #11781

Open
HertzDevil opened this issue Jan 29, 2022 · 1 comment
Open

Source code does not show for crystal eval compilation errors #11781

HertzDevil opened this issue Jan 29, 2022 · 1 comment

Comments

@HertzDevil
Copy link
Contributor

Since the standard input and the command-line argument "files" do not correspond to actual files and they do not originate from a macro expansion, compilation errors do not show any source code for crystal eval:

$ cat test.cr
foo
$ crystal test.cr
Showing last frame. Use --error-trace for full trace.

In test.cr:1:1

 1 | foo
     ^--
Error: undefined local variable or method 'foo' for top-level
$ cat test.cr | crystal eval
error in line 1
Error: undefined local variable or method 'foo' for top-level
$ crystal eval "$(cat test.cr)"
Showing last frame. Use --error-trace for full trace.

error in line 1
Error: undefined local variable or method 'foo' for top-level

The source code does have a fictitious filename of eval, and in fact, if a file with that name exists in the current directory, it will be picked up by the compiler:

$ echo abcde > eval
$ cat test.cr | crystal eval
Showing last frame. Use --error-trace for full trace.

In eval:1:1

 1 | abcde
     ^--
Error: undefined local variable or method 'foo' for top-level
@HertzDevil
Copy link
Contributor Author

It actually also happens for --stdin-filename:

$ cat test.cr | crystal build --stdin-filename x
Showing last frame. Use --error-trace for full trace.

error in line 1
Error: undefined local variable or method 'foo' for top-level
$ cat test.cr | crystal run --stdin-filename x
Showing last frame. Use --error-trace for full trace.

error in line 1
Error: undefined local variable or method 'foo' for top-level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant