300 Commits
Author SHA1 Message Date
Thomas Weber be4e8c288e Add sampler API (#394) 2026-10-18 16:32:07 -05:00
Thomas Weber 8ce06bc6a8 Import most of the forkphorus test suite (#303)
forkphorus has its own test suite, most of which are regression tests for real bugs in a real compiler so it may be worth testing against.

forkphorus-befunge-eratosthenes and forkphorus-string-functions are probably the most meaningful new test cases; at the very least i wouldn't have needed a new test case in #300 to see changes in snapshots if they were merged

The tests also add coverage for specializations like "delete 1 of list" that somehow weren't in the suite before?
2026-10-18 14:49:20 -05:00
Thomas Weber 7387fa0883 Replace tap with node:test (#393) 2026-10-18 14:43:49 -05:00
Thomas Weber 3aca9363a3 Optimize jsexecute helpers (#389)
* replace Number.isNaN -> x !== x (see https://github.com/TurboWarp/scratch-vm/pull/367 for background on this though it matters less than expected)
 * optimize listGet for numbers
 * optimize listReplace for numbers
 * optimize listDelete for first and last items
 * optimize listContains / listIndexOf by hoisting work that would previously happened inside compareEqual many times
2026-10-18 13:29:37 -05:00
Thomas Weber ec5733a9e7 Remove yields from stop all and delete clone (#392) 2026-10-18 13:05:45 -05:00
Thomas Weber 55fd9b7c95 Fix compiler error when argument name is literal number (#387) 2026-10-11 19:29:56 -05:00
Thomas Weber cb8a394fca Actually delete assets when unloaded (#382) 2026-10-11 17:17:55 -05:00
Thomas Weber 7d0d67ad9f Fix missing optimization passes on procedures with multiple variants (#383) 2026-10-11 17:09:05 -05:00
Thomas Weber 042235b193 Fix tangent (#381)
fix https://github.com/TurboWarp/scratch-vm/issues/380
2026-10-05 20:50:07 -05:00
Thomas Weber 32b5428fab Fix casting constant boolean interpretable string to number (#371)
They both should convert to 0
Fixes https://github.com/TurboWarp/scratch-vm/issues/359
2026-10-03 02:46:40 -05:00
Thomas Weber 8c62a150e1 Fix isNotActuallyZero on very small numbers (#373)
Fixes https://github.com/TurboWarp/scratch-vm/issues/361
2026-10-03 02:33:43 -05:00
Thomas Weber 984e05f83e Fix type analysis of casts with partially matching input types (#369)
Fixes https://github.com/TurboWarp/scratch-vm/issues/356
2026-10-03 01:45:28 -05:00
Thomas Weber c5bf9c3266 Fix custom reporter exit state analysis (#368)
Fixes https://github.com/TurboWarp/scratch-vm/issues/358
2026-10-03 01:39:14 -05:00
Thomas Weber 52f4369e63 Fix spork compatibility issue with mutation-less control_stop
Our editor relies on the mutation for control_stop to know if there is a connection below.
Spork does not export that mutation anymore.
Instead, we will just generate the mutation to fix errors on loading.
2026-05-03 10:27:39 -05:00
7b521ff000 Force shadow property for procedure blocks during deserialization (#335)
Co-authored-by: Cubester <78769806+CubesterYT@users.noreply.github.com>
Co-authored-by: Thomas Weber <muffin@muffin.ink>
2026-04-18 22:18:21 -05:00
Thomas Weber 7fefa6f666 Check for either input never being numbers first in OP_EQUALS
Fixes https://github.com/TurboWarp/scratch-vm/issues/311
2025-12-29 20:06:36 -06:00
Thomas Weber 0e5043d4dc Fix missing boolean cast in control_repeat_until
Fixes https://github.com/TurboWarp/scratch-vm/issues/317
2025-12-29 19:50:15 -06:00
Thomas Weber 7aa8930802 Fix incorrect types for sensing_of
They can return 0 if the sprite does not exist
Fixes https://github.com/TurboWarp/scratch-vm/issues/262
Closes https://github.com/TurboWarp/scratch-vm/pull/325
(this one uses a different fix and has tests)

There are broader issues about compiled sensing_of not handling dynamic
sprite create/delete. We should tackle that later. The other PR wouldn't
really fix this either.
2025-12-29 18:58:44 -06:00
Thomas Weber eb0d678068 Only analyze repeat block inputs at the start of the loop 2025-10-12 11:12:05 -05:00
Thomas Weber d09f82a2fe Add new test case that does some simple string operations 2025-10-08 17:15:24 -05:00
Thomas Weber 2244b26773 Discard old state after calling yielding procedure 2025-09-24 16:48:01 -05:00
Thomas Weber 4a8a5ad901 Add test case for 7ed29f5801 2025-09-22 19:30:23 -05:00
Thomas Weber 214b86a063 Add test case for d8c73c71d2 2025-09-22 19:29:06 -05:00
Thomas Weber 445a129939 Add test case for 7cc8f580b3 2025-09-22 19:28:17 -05:00
Thomas Weber c372e925a5 Add test case for 6a37fee386 2025-09-22 19:27:08 -05:00
Thomas Weber 40715dc259 Add test case for https://github.com/TurboWarp/scratch-vm/issues/276 2025-09-22 18:41:48 -05:00
Thomas Weber 44e2589e65 Fix https://github.com/TurboWarp/scratch-vm/issues/277
Need to clear the state before analyzing the condition as the condition
may be re-evaluated after yielding.
2025-09-22 18:40:34 -05:00
Thomas Weber cd353ca31e Merge pull request #268 from TurboWarp/fix-analyzeLoopedBlock-infinite-loop
Give up analyzing looped stack after 10000 iterations
2025-09-20 13:57:52 -05:00
Thomas Weber fa035541da Give up analyzing looped stack after 10000 iterations
Temporary fix for an infinite loop, to be properly fixed later
2025-09-20 13:53:41 -05:00
Thomas Weber 5b027b995e Fix motion_turnleft and motion_turnright missing type casts 2025-09-15 18:01:45 -05:00
Tacodiva d8c73c71d2 Account for stop this script in type analysis and add test 2025-09-08 15:28:11 +10:00
Tacodiva fbca1bf49b Fixed NaN = 0 wrongly reporting true, and add a test 2025-09-08 11:48:55 +10:00
Tacodiva b8defadedb Merge remote-tracking branch 'origin/develop' into HEAD 2025-09-07 11:56:25 +10:00
Thomas Weber ba9ae068ca Don't compress formats that are already compressed (#258)
Closes https://github.com/TurboWarp/scratch-vm/issues/253
2025-05-13 21:45:21 -05:00
Thomas Weber b8520ccd9a Fix visual report error when thread target does not match editing target
Fixes #252
2025-03-27 13:34:21 -05:00
Thomas Weber 7ef5e29c16 interpreter: fix skipped blocks in recursive procedures using "stop this script"
Closes https://github.com/TurboWarp/scratch-vm/issues/249
Regression from 20f25f252c
2025-03-07 01:21:08 -06:00
Muffin cd63c87f07 js: reset variable types after compatibility layer call
Fixes https://github.com/TurboWarp/scratch-vm/issues/245
2025-02-11 00:49:36 -06:00
Thomas Weber af3b7513a4 ir: Match vanilla quirks when handling variable or list fields with null ID 2025-01-18 00:29:09 -06:00
Thomas Weber 2c9d301da2 ir: Fix variable cache collision when variable or list field has null ID
Fixes https://github.com/TurboWarp/scratch-vm/issues/239
2025-01-18 00:09:09 -06:00
Tacodiva df65b01cde Merge branch 'origin/develop' into next-next 2024-09-26 11:50:09 +10:00
Muffin 179030ad49 Don't eagerly cast boolean arguments to boolean (#223)
Fixes https://github.com/TurboWarp/scratch-vm/issues/222
2024-09-08 11:56:47 -05:00
Tacodiva 1dc9aadf3f Fix issue when setting variables to InputType.ANY and add test 2024-06-25 18:25:47 +10:00
Tacodiva 71b75aad51 Add type assertion checking 2024-06-16 13:50:39 +10:00
Muffin 30a614dfc4 Expose compatibility layer stack frame on thread
For https://github.com/TurboWarp/scratch-vm/issues/212
2024-06-14 14:32:35 -05:00
Muffin 6ce931b60a Add test for behavior of self-restarting scripts
The behavior is non-trivial as it will keep running the old thread
unti it yields.

I briefly tested putting `thread.status = 4` at the start of _restartThread
and all the old execution tests still passed, so let's just add a bit more
coverage. This was nearly regressed by f548d1b33c.
2024-05-23 14:16:57 -05:00
Muffin f548d1b33c Fix stopping a thread from inside of its blocks
Works in command or reporter after yielding or not.
These snippets are covered by the tests:
thread.status = Thread.STATUS_DONE;
thread.status = 4; (indirectly)
sequencer.retireThread(thread);
2024-05-15 14:46:23 -05:00
Muffin 0593628e24 Fix rejected promise behavior in interpreter and compiler
Before this command:
- Interpreter would popStack() and continue. Inside a loop this was like JS continue, outside it was like return
- Compiler would return literal undefined and keep going.

After this commit:
Both return the error as a string and then continue as normal.
This has several benefits:
- Users can actually see the error messages
- Logical execution flow
- Consistent behavior
- Blocks aren't even supposed to return rejected promises anyways
- No vanilla blocks return rejected promises so no compatibility concerns

Supersedes https://github.com/TurboWarp/scratch-vm/pull/207
2024-05-09 00:18:18 -05:00
GarboMuffin 20f25f252c interpreter: Do not re-evaluate procedure arguments after stop this script or return (#202)
"stop this script" and "return" would previously cause all the procedure
arguments to be re-evaluated and then discarded. In vanilla Scratch the
worst case is a performance penalty, but with our custom reporters it
can cause infinite loops.

Fixes https://github.com/TurboWarp/scratch-vm/issues/201
2024-03-30 17:53:13 -05:00
Muffin a15c069ac6 Improve promise-like extension block test
notably, fail on compiler errors, and run the test block several times
2024-01-26 20:39:05 -06:00
Muffin b3e621c61b Add test for promise-like blocks 2024-01-21 13:44:54 -06:00