|
@@ -13385,7 +13385,7 @@ class TypeCheckLfun(TypeCheckLtup):
|
|
check_type_equal(param_t, arg_t, e)
|
|
check_type_equal(param_t, arg_t, e)
|
|
return return_t
|
|
return return_t
|
|
case _:
|
|
case _:
|
|
- raise Exception('type_check_exp: in call, unexpected ' + \
|
|
|
|
|
|
+ raise Exception('type_check_exp: in call, unexpected ' +
|
|
repr(func_t))
|
|
repr(func_t))
|
|
case _:
|
|
case _:
|
|
return super().type_check_exp(e, env)
|
|
return super().type_check_exp(e, env)
|
|
@@ -13411,10 +13411,13 @@ class TypeCheckLfun(TypeCheckLtup):
|
|
case Module(body):
|
|
case Module(body):
|
|
env = {}
|
|
env = {}
|
|
for s in body:
|
|
for s in body:
|
|
- match s:
|
|
|
|
- case FunctionDef(name, params, bod, dl, returns, comment):
|
|
|
|
- params_t = [t for (x,t) in params]
|
|
|
|
- env[name] = FunctionType(params_t, returns)
|
|
|
|
|
|
+ match s:
|
|
|
|
+ case FunctionDef(name, params, bod, dl, returns, comment):
|
|
|
|
+ if name in env:
|
|
|
|
+ raise Exception('type_check: function ' +
|
|
|
|
+ repr(name) + ' defined twice')
|
|
|
|
+ params_t = [t for (x,t) in params]
|
|
|
|
+ env[name] = FunctionType(params_t, returns)
|
|
self.type_check_stmts(body, env)
|
|
self.type_check_stmts(body, env)
|
|
case _:
|
|
case _:
|
|
raise Exception('type_check: unexpected ' + repr(p))
|
|
raise Exception('type_check: unexpected ' + repr(p))
|