fix(checker) minor tweaks
This commit is contained in:
@@ -15,6 +15,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
BUILTIN_SUBTYPES: dict[str, set[str]] = {
|
||||
"object": {"float", "list", "dict"},
|
||||
"float": {"int"},
|
||||
"int": {"bool"},
|
||||
}
|
||||
|
||||
@@ -224,9 +224,9 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
||||
def visit_binary_expr(self, expr: m.BinaryExpr) -> Type:
|
||||
method: Optional[str] = MIDAS_BINARY_METHODS.get(expr.operator.type)
|
||||
if method is None:
|
||||
self.logger.warning(f"Unsupported operator {expr.operator}")
|
||||
self.logger.warning(f"Unsupported operator {expr.operator.lexeme}")
|
||||
self.reporter.warning(
|
||||
expr.location, f"Unsupported operator {expr.operator}"
|
||||
expr.location, f"Unsupported operator {expr.operator.lexeme}"
|
||||
)
|
||||
return UnknownType()
|
||||
|
||||
@@ -257,9 +257,9 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
||||
def visit_unary_expr(self, expr: m.UnaryExpr) -> Type:
|
||||
method: Optional[str] = MIDAS_UNARY_METHODS.get(expr.operator.type)
|
||||
if method is None:
|
||||
self.logger.warning(f"Unsupported operator {expr.operator}")
|
||||
self.logger.warning(f"Unsupported operator {expr.operator.lexeme}")
|
||||
self.reporter.warning(
|
||||
expr.location, f"Unsupported operator {expr.operator}"
|
||||
expr.location, f"Unsupported operator {expr.operator.lexeme}"
|
||||
)
|
||||
return UnknownType()
|
||||
|
||||
@@ -303,7 +303,7 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
||||
member: Optional[Type] = self.types.lookup_member(object, expr.name.lexeme)
|
||||
if member is None:
|
||||
self.reporter.error(
|
||||
expr.location, f"Unknown member '{expr.name}' of {object}"
|
||||
expr.location, f"Unknown member '{expr.name.lexeme}' of {object}"
|
||||
)
|
||||
return UnknownType()
|
||||
return member
|
||||
|
||||
@@ -21,7 +21,7 @@ PY_OPERATOR_METHODS: dict[Type[ast.operator], str] = {
|
||||
|
||||
PY_COMPARATOR_METHODS: dict[Type[ast.cmpop], str] = {
|
||||
ast.Eq: "__eq__",
|
||||
# ast.NotEq: "__noteq__",
|
||||
ast.NotEq: "__eq__",
|
||||
ast.Lt: "__lt__",
|
||||
ast.LtE: "__le__",
|
||||
ast.Gt: "__gt__",
|
||||
@@ -52,7 +52,7 @@ MIDAS_BINARY_METHODS: dict[TokenType, str] = {
|
||||
# ast.BitAnd: "__and__",
|
||||
# ast.FloorDiv: "__floordiv__",
|
||||
TokenType.EQUAL_EQUAL: "__eq__",
|
||||
# ast.NotEq: "__noteq__",
|
||||
TokenType.BANG_EQUAL: "__eq__",
|
||||
TokenType.LESS: "__lt__",
|
||||
TokenType.LESS_EQUAL: "__le__",
|
||||
TokenType.GREATER: "__gt__",
|
||||
|
||||
Reference in New Issue
Block a user