diff --git a/Makefile b/Makefile index ac1bf09..c371232 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -WABT_DIR := /home/johan/Sources/github.com/WebAssembly/wabt +WABT_DIR := /home/johan/sources/github.com/WebAssembly/wabt WAT2WASM := $(WABT_DIR)/bin/wat2wasm WASM2C := $(WABT_DIR)/bin/wasm2c diff --git a/phasm/type3/constraints.py b/phasm/type3/constraints.py index 2fbdb42..a5017fb 100644 --- a/phasm/type3/constraints.py +++ b/phasm/type3/constraints.py @@ -16,11 +16,12 @@ class Error: This means the programmer has to make some kind of chance to the typing of their program before the compiler can do its thing. """ - def __init__(self, msg: str) -> None: + def __init__(self, msg: str, *, comment: Optional[str] = None) -> None: self.msg = msg + self.comment = comment def __repr__(self) -> str: - return f'Error({repr(self.msg)})' + return f'Error({repr(self.msg)}, comment={repr(self.comment)})' class RequireTypeSubstitutes: """ @@ -135,10 +136,10 @@ class SameTypeConstraint(ConstraintBase): for typ in known_types[1:]: if isinstance(first_type, types.AppliedType3) and isinstance(typ, types.AppliedType3): if len(first_type.args) != len(typ.args): - return Error('Mismatch between applied types argument count') + return Error('Mismatch between applied types argument count', comment=self.comment) if first_type.base != typ.base: - return Error('Mismatch between applied types base') + return Error('Mismatch between applied types base', comment=self.comment) for first_type_arg, typ_arg in zip(first_type.args, typ.args): new_constraint_list.append(SameTypeConstraint( @@ -148,7 +149,7 @@ class SameTypeConstraint(ConstraintBase): continue if typ != first_type: - return Error(f'{typ:s} must be {first_type:s} instead') + return Error(f'{typ:s} must be {first_type:s} instead', comment=self.comment) if new_constraint_list: # If this happens, make CheckResult a class that can have both