Skip to content

export default in namespace crashes compiler #2200

Closed
@romdotdog

Description

@romdotdog

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions