mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Improve expression type checking
This commit is contained in:
parent
b636d9ed71
commit
98ba7d467a
11 changed files with 160 additions and 55 deletions
|
@ -20,7 +20,7 @@
|
|||
from dataclasses import dataclass
|
||||
|
||||
from .common import *
|
||||
from .expression import ExprChain, LookupOp, IdentExpr
|
||||
from .expression import ExprChain, LookupOp, LiteralExpr
|
||||
from .contexts import ValueTypeCtx
|
||||
|
||||
|
||||
|
@ -37,10 +37,14 @@ class Binding(AstNode):
|
|||
@property
|
||||
def simple_binding(self) -> T.Optional["SimpleBinding"]:
|
||||
if isinstance(self.expression.last, LookupOp):
|
||||
if isinstance(self.expression.last.lhs, IdentExpr):
|
||||
return SimpleBinding(
|
||||
self.expression.last.lhs.ident, self.expression.last.property_name
|
||||
)
|
||||
if isinstance(self.expression.last.lhs, LiteralExpr):
|
||||
from .values import IdentLiteral
|
||||
|
||||
if isinstance(self.expression.last.lhs.literal.value, IdentLiteral):
|
||||
return SimpleBinding(
|
||||
self.expression.last.lhs.literal.value.ident,
|
||||
self.expression.last.property_name,
|
||||
)
|
||||
return None
|
||||
|
||||
@validate("bind")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue