Selaa lähdekoodia

Llambda typechecker: fixed case AnnAssign

Peter Thiemann 3 vuotta sitten
vanhempi
commit
5b90fece96
1 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 3 2
      book.tex

+ 3 - 2
book.tex

@@ -15109,13 +15109,14 @@ class TypeCheckLlambda(TypeCheckLfun):
           case _:
             raise Exception('expected a tuple, not '  + repr(tup_t))
         self.check_stmts(ss[1:], return_ty, env)
-      case AnnAssign(Name(id), ty, value, simple):
+      case AnnAssign(Name(id), ty_annot, value, simple):
         ss[0].annotation = ty_annot
         if id in env:
-            self.check_type_equal(env[id], ty)
+            self.check_type_equal(env[id], ty_annot)
         else:
             env[id] = ty_annot
         self.check_exp(value, ty_annot, env)
+        self.check_stmts(ss[1:], return_ty, env)
       case _:
         self.type_check_stmts(ss, env)