Closed
Description
Bug description
When an interface extends from a parent interface, any functions/methods that receive or return the BASE interface type will cause the compiler to crash.
Steps to reproduce
The following example code should compile fine in the typescript playground, but will crash the assemblyscript playground:
interface BaseInt {
m(): BaseInt;
}
interface MyInt extends BaseInt {
s: string;
m(): MyInt;
}
class MyClass implements MyInt {
s: string = 'foo'
m(): MyClass { return this }
}
export function main(): void {
const c = new MyClass()
test(c)
}
function test(t: BaseInt): BaseInt {
return t.m()
}
NB: change the arg/return types of the test()
function to MyInt
or MyClass
and it compiles OK. But on the base interface the following exception is thrown:
▌ 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 (file:///Users/x/Dev/x/node_modules/assemblyscript/dist/assemblyscript.js:9:3369)
▌ at eu.resolveOverrides (file:///Users/x/Dev/x/node_modules/assemblyscript/dist/asc.js:22622:94904)
▌ at As.compile (file:///Users/x/Dev/x/node_modules/assemblyscript/dist/asc.js:22872:5096)
▌ at Object.q1 (file:///Users/x/Dev/x/node_modules/assemblyscript/dist/asc.js:22910:2148)
▌ at Object.nh (file:///Users/x/Dev/x/node_modules/assemblyscript/dist/asc.js:22942:9224)
▌ at async compile (file:///Users/x/Dev/x/packages/compiler/dist/compiler.js:96:46)
▌ at async Command.compileCode (file:///Users/x/Dev/x/packages/cli/dist/cmds/compile.js:28:17)
▌ at async Command.parseAsync (/Users/x/Dev/x/node_modules/commander/lib/command.js:935:5)
▌ at async file:///Users/x/Dev/x/packages/cli/dist/cli.js:35:9
▌
▌ 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!
The error above can specifically be isolated to this LOC:
assemblyscript/src/resolver.ts
Line 3063 in a0c27fa
AssemblyScript version
#main