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

[Bug] Compiler crashes on variable shadowing #1987

Closed
evaporei opened this issue Jul 16, 2021 · 4 comments
Closed

[Bug] Compiler crashes on variable shadowing #1987

evaporei opened this issue Jul 16, 2021 · 4 comments
Labels

Comments

@evaporei
Copy link

What

The compiler crashes like this:

▌ Whoops, the AssemblyScript compiler has crashed during compile :-(
▌
▌ Here is a stack trace that may or may not be useful:
▌
▌ AssertionError: assertion failed
▌     at i.assert (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:737201)
▌     at p.addScopedDummyLocal (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:416126)
▌     at f.compileVariableStatement (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:232586)
▌     at f.compileStatement (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:223388)
▌     at f.compileStatements (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:223935)
▌     at f.compileFunctionBody (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:213143)
▌     at f.compileFunction (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:212127)
▌     at f.compileElement (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:204050)
▌     at f.compileExports (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:204790)
▌     at f.compile (/usr/local/lib/node_modules/asbuild/node_modules/assemblyscript/dist/assemblyscript.js:7:195042)
▌
▌ If it refers to the dist files, try to 'npm install source-map-support' and
▌ run again, which should then show the actual code location in the sources.
▌
▌ If you see where the error is, feel free to send us a pull request. If not,
▌ please let us know: https://github.com/AssemblyScript/assemblyscript/issues
▌
▌ Thank you!

スクリーンショット 2021-07-15 23 26 51

When

Doing variable shadowing like this:

export function foo(): i32 {
  let a = 20 + 20;
  let b = 50;
  let a = a + b;
  return 42;
}

Expected

It would be nice to have some kind of user friendly error message on this. It seems like a very simple error, but the problem is that I'm working in a huge codebase and it was a bit annoying to find that it was a problem with variable shadowing.

Context

By the way I only got this problem because we're updating from v0.6 to v0.19, so yeah quite a big jump 😅 .
And yeah, shadowing didn't seem to be a problem back then.

I have no problems in this feature not existing anymore (variable shadowing), I would just be more pleased to have a better error message, if possible 😊 .

Thanks

Also, huge thanks for this project, we use extensively here at The Graph (@graphprotocol).

@evaporei evaporei changed the title Compiler crashes on variable shadowing [Bug] Compiler crashes on variable shadowing Jul 16, 2021
@dcodeIO dcodeIO added the bug label Jul 16, 2021
@dcodeIO
Copy link
Member

dcodeIO commented Jul 16, 2021

Hmm, this looks like it would generate the proper diagnostic about a duplicate name, but before it is able to emit it hits the assertion otherwise. Definitely a bug, thanks!

HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jul 24, 2021
HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jul 24, 2021
HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jul 24, 2021
HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jul 24, 2021
HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jul 24, 2021
@romdotdog
Copy link
Contributor

close issue

@MaxGraey
Copy link
Member

not yet shipped. But it fixed in (#2002)

@evaporei
Copy link
Author

evaporei commented Aug 7, 2021

It has been shipped on v0.19.10! 🎉

@evaporei evaporei closed this as completed Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants