class Decl(FooNode): names = Field() env_spec = EnvSpec(do(PropertyError(T.FooNode)), add_env()) @langkit_property(public=True) def lookup(n=T.Name.entity): return Entity.node_env.get_first(n.symbol)
def resolve(lhs=T.FooNode.entity, rhs=T.FooNode.entity): eq = Var( All([ NPropagate(Self.v, T.Literal.combiner, Self.lhs.v, Self.rhs.v), Bind(Self.lhs.v, lhs), Bind(Self.rhs.v, rhs), ])) return If(eq.solve, Self.v.get_value, PropertyError(T.FooNode.entity, "unreachable"))
class Scope(Def): error = Field() name = Field() defs = Field() env_spec = EnvSpec( add_to_env(New(T.env_assoc, key=Self.name.symbol, val=Self)), add_env(), do(If(Self.error.as_bool, PropertyError(T.FooNode), No(T.FooNode))), )
def raise_no_msg(): return PropertyError(T.Bool)
def raise_msg(): return PropertyError(T.Bool, 'Custom error message!')
def internal_mmz_prop(i=T.Int): return If(i == 0, PropertyError(T.Int), i)
def failing_property(): return PropertyError(T.Bool)
def prop2(): return PropertyError(Bool, 'Explicit error 2')
def prop1(): ignore(Var(Self.singleton)) return PropertyError(Bool, 'Explicit error 1')
def resolve(): return PropertyError(T.LexicalEnv, "unconditionally raised")
def resolve(): return PropertyError(T.LexicalEnv)