Skip to main content

Module cast_check

Module cast_check 

Source
Expand description

The structural conformance test and its consumers: x as T, the ! non-null assertion, and the read guard on a narrowed field redeclaration.

Constants§

TYPE_TAG_STRINGS

Functions§

emit_cast
value as target_ty. check is Some(shape) when a runtime structural check is needed (the source isn’t a static subtype of the target — unknown/downcasts); None for a statically-proven upcast (repr-only narrow). shape has interfaces reduced to their object shapes so this walks plain structural types. cast_span is the cast expression’s own span, mapped while its runtime check is emitted so a limit the check reaches, and a failed check, are reported at the cast rather than at the last part of the value. The code after the cast maps to the enclosing span again.
emit_narrowed_field_read
emit_non_null_assert
value!. Converts a runtime null into a catchable TypeError instead of relying on ref.as_non_null, which would trap.
emit_non_null_assert_on_stack
! applied to a value already on the stack at source_ty’s slot — the optional-chain form, where the operand is the step before rather than an expression this can emit itself.
error_prefix