Skip to content

Issue for ir.Method in IList lowering #656

@kaihsin

Description

@kaihsin

The following mwe produce the error when lowering from python syntax/AST

MWE:

from kirin.prelude import basic

@basic
def main():
    return 3

@basic
def main2():    
    return 4


@basic
def main_final():
    return [main, main2]

Error msg:

Traceback (most recent call last):
  File "/home/kaihsinwu/kirin-workspace/tst.py", line 13, in <module>
    @basic
     ^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/ir/group.py", line 274, in __call__
    return wrapper(py_func)
           ^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/ir/group.py", line 228, in wrapper
    code = self.lowering.python_function(py_func, lineno_offset=lineno_offset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/lowering.py", line 72, in python_function
    region = self.run(
             ^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/lowering.py", line 112, in run
    self.visit(state, stmt)
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/lowering.py", line 147, in visit
    return self.registry.ast_table[name].lower(state, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/dialect.py", line 72, in lower
    return getattr(self, f"lower_{node.__class__.__name__}", self.unreachable)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/dialects/lowering/func.py", line 63, in lower_FunctionDef
    func_frame.exhaust()
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/frame.py", line 159, in exhaust
    self.state.parent.visit(self.state, stmt)
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/lowering.py", line 147, in visit
    return self.registry.ast_table[name].lower(state, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/dialect.py", line 72, in lower
    return getattr(self, f"lower_{node.__class__.__name__}", self.unreachable)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/dialects/lowering/func.py", line 18, in lower_Return
    result = state.lower(node.value).expect_one()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/state.py", line 101, in lower
    result = self.parent.visit(self, node)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/lowering.py", line 147, in visit
    return self.registry.ast_table[name].lower(state, node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/lowering/python/dialect.py", line 72, in lower
    return getattr(self, f"lower_{node.__class__.__name__}", self.unreachable)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/dialects/ilist/lowering.py", line 24, in lower_List
    return state.current_frame.push(ilist.New(values=tuple(elts), elem_type=typ))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/dialects/ilist/stmts.py", line 45, in __init__
    result_type = IListType[elem_type, types.Literal(len(values))]
                  ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/ir/attrs/types.py", line 628, in __getitem__
    return self.where(typ)
           ^^^^^^^^^^^^^^^
  File "/home/kaihsinwu/kirin-workspace/kirin/src/kirin/ir/attrs/types.py", line 645, in where
    raise TypeError("Type arguments do not match")
TypeError: Type arguments do not match

Metadata

Metadata

Assignees

Labels

P-HighPriority: high priority issues and tasks.category: bugCategory: this is a bug or something isn't working as expected.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions