Skip to content
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

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

Open
jay86cn opened this issue Jun 2, 2023 · 4 comments · May be fixed by #7
Open

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

jay86cn opened this issue Jun 2, 2023 · 4 comments · May be fixed by #7

Comments

@jay86cn
Copy link

jay86cn commented Jun 2, 2023

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

"ecmassembly": "^0.1.8", works fine

@trusktr
Copy link
Member

trusktr commented Jun 3, 2023

@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.

@CountBleck
Copy link

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.)

@trusktr
Copy link
Member

trusktr commented Jun 8, 2023

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.

@CountBleck CountBleck linked a pull request Jun 10, 2023 that will close this issue
@Twiggeh
Copy link

Twiggeh commented Aug 4, 2024

Any chance this is going to get merged ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants