feat(gen): add assertion collector to TypedAST

This commit is contained in:
2026-07-02 17:09:50 +02:00
parent bd4d793ce0
commit 47b2dfdd73
3 changed files with 5 additions and 0 deletions

View File

@@ -115,6 +115,7 @@ class PythonTyper(
stmts=stmts, stmts=stmts,
judgements=self.judgements, judgements=self.judgements,
evaluated_casts=self.evaluated_casts, evaluated_casts=self.evaluated_casts,
assertions=self.assertions,
) )
def judge(self, expr: p.Expr, type: Type): def judge(self, expr: p.Expr, type: Type):

View File

@@ -30,6 +30,7 @@ from midas.checker.types import (
UnitType, UnitType,
UnknownType, UnknownType,
) )
from midas.generator.collector import Assertion, AssertionCollector
from midas.generator.constraints import ConstraintGenerator from midas.generator.constraints import ConstraintGenerator
from midas.generator.stubs import StubsGenerator from midas.generator.stubs import StubsGenerator
from midas.utils import TypedAST from midas.utils import TypedAST
@@ -55,6 +56,7 @@ class Generator(p.Stmt.Visitor[ast.stmt], p.Expr.Visitor[ast.expr]):
stmts=[], stmts=[],
judgements=[], judgements=[],
evaluated_casts=[], evaluated_casts=[],
assertions=AssertionCollector(),
) )
self._alias_count: int = 0 self._alias_count: int = 0
self._predicate_count: int = 0 self._predicate_count: int = 0

View File

@@ -3,6 +3,7 @@ from typing import Any, Callable, Optional
import midas.ast.python as p import midas.ast.python as p
from midas.checker.types import Type from midas.checker.types import Type
from midas.generator.collector import AssertionCollector
AllowRepeat = Callable[[object], bool] AllowRepeat = Callable[[object], bool]
@@ -63,3 +64,4 @@ class TypedAST:
stmts: list[p.Stmt] stmts: list[p.Stmt]
judgements: list[tuple[p.Expr, Type]] judgements: list[tuple[p.Expr, Type]]
evaluated_casts: list[p.CastExpr] evaluated_casts: list[p.CastExpr]
assertions: AssertionCollector