Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guppylang.error.InternalGuppyError: Unexpected assignment pattern #736

Open
aborgna-q opened this issue Dec 19, 2024 · 0 comments · May be fixed by #738
Open

guppylang.error.InternalGuppyError: Unexpected assignment pattern #736

aborgna-q opened this issue Dec 19, 2024 · 0 comments · May be fixed by #738
Assignees

Comments

@aborgna-q
Copy link
Collaborator

aborgna-q commented Dec 19, 2024

module = GuppyModule("test")
@guppy(module)
def main() -> None:
    bs = [True]
    bs[0] = bs[0]

Running this errors out with

guppylang/error.py:101: in pretty_errors_wrapped
    return f(*args, **kwargs)
guppylang/module.py:346: in compile
    self.check()
guppylang/module.py:323: in check
    other_defs = self._check_defs(
guppylang/module.py:295: in _check_defs
    defn.check(parsed_globals) if isinstance(defn, CheckableDef) else defn
guppylang/definition/function.py:106: in check
    cfg = check_global_func_def(self.defined_at, self.ty, globals)
guppylang/checker/func_checker.py:80: in check_global_func_def
    return check_cfg(cfg, inputs, ty.output, generic_params, func_def.name, globals)
guppylang/checker/cfg_checker.py:84: in check_cfg
    checked_cfg.entry_bb = check_bb(
guppylang/checker/cfg_checker.py:200: in check_bb
    checked_stmts = StmtChecker(ctx, bb, return_ty).check_stmts(bb.statements)
guppylang/checker/stmt_checker.py:91: in check_stmts
    return [self.visit(s) for s in stmts]
guppylang/ast_util.py:53: in visit
    return visitor(node, *args, **kwargs)
guppylang/checker/stmt_checker.py:279: in visit_Assign
    node.targets = [self._check_assign(target, node.value, ty)]
../../.local/share/uv/python/cpython-3.12.5-macos-aarch64-none/lib/python3.12/functools.py:944: in _method
    return method.__get__(obj, cls)(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <guppylang.checker.stmt_checker.StmtChecker object at 0x1117337d0>
lhs = <ast.Subscript object at 0x1117aec10>
rhs = <guppylang.nodes.PlaceNode object at 0x111710290>
rhs_ty = OpaqueType(args=[], defn=OpaqueTypeDef(id=DefId(id=3, module=None), name='bool', defined_at=None, description='type', params=[], always_linear=False, to_hugr=<function <lambda> at 0x11115dc60>, bound=None))

    @functools.singledispatchmethod
    def _check_assign(self, lhs: ast.expr, rhs: ast.expr, rhs_ty: Type) -> ast.expr:
        """Helper function to check assignments with patterns."""
>       raise InternalGuppyError("Unexpected assignment pattern")
E       guppylang.error.InternalGuppyError: Unexpected assignment pattern

guppylang/checker/stmt_checker.py:104: InternalGuppyError

I'd expect this to emit a nicer error rather than panic internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants