microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
721 stars 594 forks source link

Incorrect Code Validation Error in Hamster Tutorial #5940

Closed thsparks closed 1 month ago

thsparks commented 1 month ago

On step 4 of the hamster tutorial (or any other step expecting play sound blocks), we get a code validation failure popup even if the correct block is in place. Probably something to do with the switch to non-deprecated blocks, though the hint looks correct so I'm not sure yet where the issue lies, if it's just updating tutorial content or some issue with the compilation/block parsing.

image

image

ganicke commented 1 month ago

@thsparks, @abchatra - the problem here is that the blocks decompile doesn't match the hint code source in ```blocks. You see that the hint contains:

basic.showIcon(IconNames.Asleep)
input.onLogoEvent(TouchButtonEvent.Pressed, function () {
    basic.showIcon(IconNames.Happy)
    //@highlight
    music.play(music.builtInPlayableMelody(Melodies.JumpUp), music.PlaybackMode.UntilDone)
})

...but the result for the code dragged over from the workspace has the play() method converted into the helper of _playDefaultBackground():

input.onLogoEvent(TouchButtonEvent.Pressed, function () {
    basic.showIcon(IconNames.Happy)
    music._playDefaultBackground(music.builtInPlayableMelody(Melodies.JumpUp), music.PlaybackMode.UntilDone)
})
basic.showIcon(IconNames.Asleep)

I've verified that the validation succeeds when I replace play() with _playDefaultBackground().

This is even visually evident when you look at the "Show Me" and see the difference in the melody parameter:

image

So, what's the fix here? Replace the all the occurrences of play() with _playDefaultBackground()?

abchatra commented 1 month ago

@riknoll ?

thsparks commented 1 month ago

Seems odd to me that it's compiling to _ blocks like that, so we probably want to see about fixing that...But I'd still say we should fix the tutorials for now. Bug is pretty annoying if you're going through the tutorials, and it's out in live right now. We can switch them back later if needed, if we do decide to switch it to a non-hidden function.

thsparks commented 1 month ago

Probably a result of my changes to these blocks from last year