Skip to content

Commit 1c39ed2

Browse files
fix(name-resolve): Fix parameter type handling, fixes #66
1 parent e1d39ba commit 1c39ed2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

parser/typecheck/typecheck.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ def enter_fn_decl(fn: AstDefine):
155155
raise self.err("Function already declared", fn.ident.region)
156156
subscope = Scope()
157157
params: list[ParamInfo] = []
158-
for tp, param in fn.params:
159-
if tp.id not in PARAM_TYPES:
160-
raise self.err("Unknown parameter type", tp.region)
161-
if param.id in subscope.declared:
162-
raise self.err("There is already a parameter of this name", param.region)
163-
tp = BoolType() if param.id == 'bool' else ValType()
164-
subscope.declared[param.id] = NameInfo(subscope, param.id, tp, is_param=True)
165-
params.append(ParamInfo(param.id, tp))
158+
for tp_node, name_node in fn.params:
159+
if tp_node.id not in PARAM_TYPES:
160+
raise self.err("Unknown parameter type", tp_node.region)
161+
if (name := name_node.id) in subscope.declared:
162+
raise self.err("There is already a parameter of this name",
163+
name_node.region)
164+
tp = BoolType() if tp_node.id == 'bool' else ValType()
165+
subscope.declared[name] = NameInfo(subscope, name, tp, is_param=True)
166+
params.append(ParamInfo(name, tp))
166167
curr_scope.declared[ident] = info = FuncInfo.from_param_info(
167168
curr_scope, ident, params,
168169
ret_type=VoidType(), subscope=subscope)

0 commit comments

Comments
 (0)