mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
A union, unknown or any value is converted to a dynamic value before it is thrown, and promise rejections and other runtime throws carry dynamic values too. A catch binding then holds a dynamic payload, which the native class test does not recognize: `e instanceof C` was false for every class of a hierarchy, and a read narrowed by it trapped. A test through a parameter of type unknown was already correct. When a class or one of its subclasses crosses into unknown, the class dynamic-dispatch pass now routes the catch-binding tests of that class (`e instanceof C`, the reads it narrows and `e as C`) through helpers that keep the native test and answer a dynamic payload with the dynamic class test, as standalone classes already do. The new "dynamic" caught test selects that payload, so native payloads are not converted. Programs whose classes never cross into unknown compile as before.