From 78c98b1e61051af62f4ac2e2436ba8cf5d0d19a1 Mon Sep 17 00:00:00 2001 From: "Johan B.W. de Vries" Date: Sat, 10 May 2025 16:51:38 +0200 Subject: [PATCH] Fix: Type error That's what I get for cleaning up without running tests. This removes a intermediate hack to detect missing routes. --- phasm/compiler.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/phasm/compiler.py b/phasm/compiler.py index 328f04d..4b90740 100644 --- a/phasm/compiler.py +++ b/phasm/compiler.py @@ -385,18 +385,17 @@ def tuple_instantiation(wgn: WasmGenerator, inp: ourlang.TupleInstantiation) -> def expression_subscript_bytes( attrs: tuple[WasmGenerator, ourlang.Subscript], - ) -> bool: + ) -> None: wgn, inp = attrs expression(wgn, inp.varref) expression(wgn, inp.index) wgn.call(stdlib_types.__subscript_bytes__) - return True def expression_subscript_static_array( attrs: tuple[WasmGenerator, ourlang.Subscript], args: tuple[type3types.Type3, type3types.IntType3], - ) -> bool: + ) -> None: wgn, inp = attrs el_type, el_len = args @@ -424,12 +423,11 @@ def expression_subscript_static_array( mtyp = LOAD_STORE_TYPE_MAP[el_type.name] wgn.add_statement(f'{mtyp}.load') - return True def expression_subscript_tuple( attrs: tuple[WasmGenerator, ourlang.Subscript], args: tuple[type3types.Type3, ...], - ) -> bool: + ) -> None: wgn, inp = attrs assert isinstance(inp.index, ourlang.ConstantPrimitive) @@ -451,9 +449,8 @@ def expression_subscript_tuple( mtyp = LOAD_STORE_TYPE_MAP[el_type.name] wgn.add_statement(f'{mtyp}.load', f'offset={offset}') - return True -SUBSCRIPT_ROUTER = type3types.TypeApplicationRouter[tuple[WasmGenerator, ourlang.Subscript], bool]() +SUBSCRIPT_ROUTER = type3types.TypeApplicationRouter[tuple[WasmGenerator, ourlang.Subscript], None]() SUBSCRIPT_ROUTER.add_n(prelude.bytes_, expression_subscript_bytes) SUBSCRIPT_ROUTER.add(prelude.static_array, expression_subscript_static_array) SUBSCRIPT_ROUTER.add(prelude.tuple_, expression_subscript_tuple) @@ -590,7 +587,8 @@ def expression(wgn: WasmGenerator, inp: ourlang.Expression) -> None: assert inp.varref.type3 is not None, TYPE3_ASSERTION_ERROR # Type checker guarantees we don't get routing errors - return SUBSCRIPT_ROUTER((wgn, inp, ), inp.varref.type3) + SUBSCRIPT_ROUTER((wgn, inp, ), inp.varref.type3) + return if isinstance(inp, ourlang.AccessStructMember): assert inp.struct_type3 is not None, TYPE3_ASSERTION_ERROR