Skip to content

Compiler crashes when using ref_extern member variable in class #2726

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
ijsf opened this issue Jul 24, 2023 · 1 comment
Closed

Compiler crashes when using ref_extern member variable in class #2726

ijsf opened this issue Jul 24, 2023 · 1 comment
Labels

Comments

@ijsf
Copy link

ijsf commented Jul 24, 2023

Bug description

The compiler crashes whenever a ref_extern is used as a member variable of a class. Also happens for similar reference types (e.g. ref_func) or nullable reference types (e.g. externref).

Steps to reproduce

Use the following code:

class MyWrapper {
  ref: externref;
}
let mywrapper = new MyWrapper();

This causes a compiler assertion:

Whoops, the AssemblyScript compiler has crashed during compile :-(
▌
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌
▌ AssertionError: assertion failed
▌     at Y.assert (.\wasm\node_modules\assemblyscript\std\portable\index.js:216:11)
▌     at Kn.finishResolveClass (.\wasm\node_modules\assemblyscript\src\resolver.ts:3433:19)
▌     at Kn.resolveClass (.\wasm\node_modules\assemblyscript\src\resolver.ts:3222:10)
▌     at Kn.resolveClassInclTypeArguments (.\wasm\node_modules\assemblyscript\src\resolver.ts:3652:17)
▌     at jr.compileNewExpression (.\wasm\node_modules\assemblyscript\src\compiler.ts:8710:37)
▌     at jr.compileExpression (.\wasm\node_modules\assemblyscript\src\compiler.ts:3397:21)
▌     at jr.compileGlobal (.\wasm\node_modules\assemblyscript\src\compiler.ts:1183:25)
▌     at jr.compileTopLevelStatement (.\wasm\node_modules\assemblyscript\src\compiler.ts:2125:20)
▌     at jr.compileFile (.\wasm\node_modules\assemblyscript\src\compiler.ts:1099:12)
▌     at jr.compile (.\wasm\node_modules\assemblyscript\src\compiler.ts:548:14)
▌
▌ 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!

AssemblyScript version

0.27.6

@ijsf ijsf added the bug label Jul 24, 2023
CountBleck added a commit to CountBleck/assemblyscript that referenced this issue Aug 13, 2023
Since reference types can't be written to linear memory, they don't have
proper byte sizes, which triggers an assert. Instead, the compiler
should signal its lack of support for this feature.

Fixes AssemblyScript#2726.
@dcodeIO
Copy link
Member

dcodeIO commented Aug 13, 2023

Fixed by emitting a proper "Not implemented" error in #2733, thanks @CountBleck!

@dcodeIO dcodeIO closed this as completed Aug 13, 2023
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

2 participants