lume/asdom

Cannot find name '__instanceof'. in the "assemblyscript": "^0.27.5",

Opened this issue · 4 comments

Cannot find name '__instanceof'. in the "assemblyscript": "^0.27.5",

"ecmassembly": "^0.1.8", works fine

@ayin86 Hmmm, the last version of AS that I used with asdom was ^0.19.5.

Maybe @dcodeIO or @MaxGraey know the error and can suggest the migration path.

AssemblyScript/assemblyscript#2555 is the relevant PR, and it removes __instanceof entirely from the compiler.
A workaround could be renaming asdom's Object to, say, JSObject, and changing __finalize.ts like so:

import {releaseObject} from './imports'
import {JSObject} from './JSObject'

// @ts-ignore
@global
function __finalize(ptr: usize): void {
	if (changetype<Object>(ptr) instanceof JSObject) {
		releaseObject(ptr)
	}
}

This snippet takes advantage of AssemblyScript/assemblyscript#2559, where Object becomes the implicit base class. (This PR was created in response to ASON's breakage from the __instanceof removal.) The new code should have the same behavior as the old code, although the internals are different (switch-case vs. RTTI in memory).

Implementing this change would break users of asdom that use AS versions below v0.24, but not implementing a workaround would keep all AS versions at and above v0.23 broken. (It's not feasible to support v0.23.x, which has neither __instanceof nor Object.)

Thanks for the analysis @CountBleck! I think it is fine to move forward with support only for the latest AssemblyScript, and providing a note about migration if needed. We don't have the time/resources to maintain workarounds for multiple versions, so getting it up to date with only the latest AS would be ok.

Any chance this is going to get merged ?