Skip to content

export default in namespace crashes compiler #2200

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

Closed
romdotdog opened this issue Feb 12, 2022 · 0 comments · Fixed by #2267
Closed

export default in namespace crashes compiler #2200

romdotdog opened this issue Feb 12, 2022 · 0 comments · Fixed by #2267
Labels

Comments

@romdotdog
Copy link
Contributor

romdotdog commented Feb 12, 2022

Code

namespace Foo {
  export default foo;
}

Try it in the playground

Stack trace

▌ Whoops, the AssemblyScript compiler has crashed during initialize :-(
▌ 
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌ 
▌ AssertionError: assertion failed
▌     at assert (D:\assemblyscript\std\portable\index.js:200:11)
▌     at Program.initializeNamespace (D:\assemblyscript\src\program.ts:2545:18)
▌     at Program.initialize (D:\assemblyscript\src\program.ts:1114:18)
▌     at Object.initializeProgram (D:\assemblyscript\src\index.ts:274:11)
▌     at D:\assemblyscript\cli\asc.js:886:22
▌     at measure (D:\assemblyscript\cli\asc.js:1409:3)
▌     at Object.main (D:\assemblyscript\cli\asc.js:884:27)
▌     at runTest (D:\assemblyscript\tests\compiler.js:178:7)
▌     at Array.forEach (<anonymous>)
▌     at D:\assemblyscript\tests\compiler.js:557:16
▌     at processTicksAndRejections (node:internal/process/task_queues:96:5)
▌ 
▌ 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!

What now?

There's a confusing error (in my opinion) that TypeScript generates in this case

A default export can only be used in an ECMAScript-style module.

I think a custom error for this case would be more informative than the above.

@dcodeIO dcodeIO added the bug label Feb 16, 2022
technohippy added a commit to technohippy/assemblyscript that referenced this issue Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants