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

Abstract TypeScript methods do not work #6030

Open
lobodpav opened this issue Dec 7, 2024 · 0 comments
Open

Abstract TypeScript methods do not work #6030

lobodpav opened this issue Dec 7, 2024 · 0 comments

Comments

@lobodpav
Copy link

lobodpav commented Dec 7, 2024

Describe the bug

When extending an abstract class with an abstract method, the pxt build fails.

To Reproduce

Run pxt build for the program below.

abstract class AbstractPlayer {
    abstract play(): void
}

class Player extends AbstractPlayer {
    play(): void {
        music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.UntilDone)
    }
}

const player = new Player()
player.play()

The compilation fails with

INTERNAL ERROR: Error: Assertion failed
    at Object.assert (/Users/pavel/Git/Microbit/makecode/node_modules/pxt-core/built/pxt.js:98695:27)
    at getVTable (/Users/pavel/Git/Microbit/makecode/node_modules/pxt-core/built/pxt.js:133474:32)
    at emitVTables (/Users/pavel/Git/Microbit/makecode/node_modules/pxt-core/built/pxt.js:134517:21)
    at Object.compileBinary (/Users/pavel/Git/Microbit/makecode/node_modules/pxt-core/built/pxt.js:133162:13)
    at Object.compile (/Users/pavel/Git/Microbit/makecode/node_modules/pxt-core/built/pxt.js:137199:40)
    at /Users/pavel/Git/Microbit/makecode/node_modules/pxt-core/built/pxt.js:165353:21
make: *** [build] Error 20

When changing the AbstractPlayer to

abstract class AbstractPlayer {
    play(): void {}
}

The compilation succeeds and the code works well on micro:bit.

Expected behavior
The compilation should succeed.

Desktop (please complete the following information):

  • OS: macOS Sequoia 15.1.1
  • target: v7.1.15
  • pxt-core v11.3.3
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

No branches or pull requests

1 participant