Skip to content

[Bug] this isn't handled when adding methods to prototypes #248

Open
@SarahIsWeird

Description

@SarahIsWeird

Basically what it says on the tin. This also affects #247, when it is merged. This is a very niche thing, but it would be cool to handle. The issue is that it is quite difficult to handle, as it can happen anywhere.

Presumably fixing this would involve adding extends Object to every class declaration. However, I'm unsure if there are some built-in classes that could be extended this way, i.e. if Hackmud freezes all classes, so that needs some investigation. Because in that case, we can't do the super.valueOf() trick, if the class doesn't have some superclass.

Repro script
class Foo {
    a() {
        this.b = 1
    }
}

Foo.prototype.getB = function() {
    return this.b
}

const bar = {
    a() {
        this.b = 1
    }
}

bar.getB = function() {
    return this.b
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions