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

Invalid syntax is not properly handled. #84

Closed
ytoml opened this issue Aug 26, 2022 · 4 comments
Closed

Invalid syntax is not properly handled. #84

ytoml opened this issue Aug 26, 2022 · 4 comments
Labels
bug Something isn't working bug-compiler

Comments

@ytoml
Copy link
Contributor

ytoml commented Aug 26, 2022

Describe the bug
When some tokens are passed without operator (thus Invalid Syntax), compiler trys to report error upsets.

Reproducible code
Just writing literals without operators in a row:

>>> 1 2 3

produces:

Error[#0000]: File <stdin>
?│ 1 2 3

CompilerSystemError: the number of elements in the stack is invalid (num of elems: 3, block id: 1)
this is a bug of the Erg compiler, please report it (https://github.com/erg-lang/erg)
caused from: erg_compiler::codegen::CodeGenerator::codegen
Traceback (most recent call last):
  File "<string>", line 17, in <module>
ConnectionResetError: [Errno 54] Connection reset by peer

Expected behavior
Expected that REPL just reports Invalid Syntax Error.

@ytoml ytoml added the bug Something isn't working label Aug 26, 2022
@ytoml
Copy link
Contributor Author

ytoml commented Aug 26, 2022

I also found that it could accept invalid statement:

Erg interpreter 0.2.8 (tags/?:, 2022/08/25 23:56:48) on aarch64/macos
>>> x = 1 2

And with these inputs(just x, twice) after above, REPL server suddenly shuts down without meaningful messages:

>>> x

>>> x
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', /Users/ytomida/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/erg-0.2.8/src/dummy.rs:69:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@mtshiba
Copy link
Member

mtshiba commented Aug 28, 2022

These codes are actually syntactically acceptable; the call syntax in Erg is of the form call := callable method_name? args, and any object callable that implements Callable trait can be called (this is a specification inherited from Python).
Of course, Int is not Callable, so the type checker should cause an error, but it is crashing, so that is the problem.

@mtshiba
Copy link
Member

mtshiba commented Aug 30, 2022

It is still as strange as ever, but it is no longer a crash.

>>> 1 2
2
>>> x = 1 2
2
>>> 1 2 3
3

@mtshiba
Copy link
Member

mtshiba commented Aug 30, 2022

This has become a parsing issue, so this issue is closed.
Please see here for the rest of the issue.

#95

@mtshiba mtshiba closed this as completed Aug 30, 2022
@mtshiba mtshiba mentioned this issue Sep 11, 2022
mtshiba added a commit that referenced this issue Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bug-compiler
Projects
None yet
Development

No branches or pull requests

2 participants