fixed return bug
This commit is contained in:
parent
69cf20cb91
commit
c99995adc6
@ -133,12 +133,13 @@ def parse_for_stmt(ctx: Context,
|
||||
if key in used_sym_table:
|
||||
if value != used_sym_table[key]:
|
||||
raise CustomError('inconsistent type')
|
||||
a, b, r = parse_stmts(ctx, sym_table | binding, used_sym_table | binding,
|
||||
# more sophisticated return analysis is needed...
|
||||
a, b, _ = parse_stmts(ctx, sym_table | binding, used_sym_table | binding,
|
||||
return_ty, node.body)
|
||||
a1, b1, r1 = parse_stmts(ctx, sym_table, used_sym_table | b,
|
||||
a1, b1, _ = parse_stmts(ctx, sym_table, used_sym_table | b,
|
||||
return_ty, node.orelse)
|
||||
defined = {k: a[k] for k in a if k in a1}
|
||||
return defined, b | b1, r and r1
|
||||
return defined, b | b1, False
|
||||
|
||||
def parse_while_stmt(ctx: Context,
|
||||
sym_table: dict[str, Type],
|
||||
@ -149,11 +150,11 @@ def parse_while_stmt(ctx: Context,
|
||||
if ty != ctx.types['bool']:
|
||||
raise CustomError('condition must be bool')
|
||||
# more sophisticated return analysis is needed...
|
||||
a, b, r = parse_stmts(ctx, sym_table, used_sym_table, return_ty, node.body)
|
||||
a1, b1, r1 = parse_stmts(ctx, sym_table, used_sym_table | b,
|
||||
a, b, _ = parse_stmts(ctx, sym_table, used_sym_table, return_ty, node.body)
|
||||
a1, b1, _ = parse_stmts(ctx, sym_table, used_sym_table | b,
|
||||
return_ty, node.orelse)
|
||||
defined = {k: a[k] for k in a if k in a1}
|
||||
return defined, b | b1, r and r1
|
||||
return defined, b | b1, False
|
||||
|
||||
def parse_return_stmt(ctx: Context,
|
||||
sym_table: dict[str, Type],
|
||||
|
Loading…
Reference in New Issue
Block a user