Skip to content

Crash on invalid abstract export class declaration inside a namespace #3045

Description

@hungryzzz

Bug description

Hi, I found that asc crashes while compiling the following AssemblyScript code snippet. I would expect a normal compilation error rather than a compiler crash.

Steps to reproduce

// bad.ts
namespace N {
  abstract export class C {}
}
> node ~/assemblyscript/bin/asc --optimizeLevel 2 --shrinkLevel 2 bad.ts -o bad.wasm

Output:

▌ 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 Y.assert (~/assemblyscript/std/portable/index.js:216:11)
▌     at On.initializeNamespace (~/assemblyscript/src/program.ts:2813:18)
▌     at On.initialize (~/assemblyscript/src/program.ts:1144:18)
▌     at Module.MS (~/assemblyscript/src/index-wasm.ts:354:11)
▌     at Module.De (~/assemblyscript/cli/index.js:714:22)
▌     at async file:///~/assemblyscript/bin/asc.js:33:22

Other findings

  1. The valid modifier order inside a namespace does not crash:
namespace N {
  export abstract class C {}
}
  1. The same invalid modifier order at the top level reports a normal compilation error instead of crashing:
// good.ts
abstract export class C {}

// ~/warpo/build/warpo/warpo_asc --optimizeLevel 2 --shrinkLevel 2 good.ts -o mutant.wasm

// compilation failed
// ERROR TS2304: Cannot find name 'abstract'.
//    :
//  2 │ abstract export class C{}
//    │ ~~~~~~~~
//    └─ in good.ts(2,1)

// ERROR: compilation failed

AssemblyScript version

b6bda05

Activity

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

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