I have a name that references a member of an entity defined elsewhere. My NaBL rules seem to be correct, as it references the correct definition, but when I want to get that definition in TS, definition of always fails:

ObjectPropAssign(name, exp) :-
where exp : exp-ty
  and definition of name has type ty
  and (exp-ty == ty
 else error $[Type mismatch! Expected '[ty]', got '[exp-ty]'.] on exp)

On this example code:

Foo { name := 10 }

…the definition of name is correctly inferred by NaBL, as changing name to something else causes an Unresolved reference. The analyzed AST is this:

ObjectCreation(TypeRef("Foo"{Use(Result(961))}), [
    ObjectPropAssign("name"{Use(Result(1272))}, Int("10"){(Type(), Result(1169))})
]{Scope([(NablNsThis(), URI(Language("TestProject"), [Anonymous("test.tes/1")]))])}
)

It generates this error, with the ty variable empty:

Type mismatch! Expected '', got ‘TypeRef(“Int”)’.

These are the relevant syntax and NaBL binding rules I’m using:

context-free syntax

    ObjectCreation.ObjectCreation     = <<TypeRef> { <ObjectPropAssign*> }>
    ObjectPropAssign.ObjectPropAssign = <<ID> := <Exp>>

binding rules
    
    ObjectCreation(ty, body):
        implicitly defines This This() of type e in body
        where definition of ty => e

    ObjectPropAssign(nm, exp):
        refers to EntityProperty nm in Entity e
        where This() resolves to This this and this has type e

I can’t figure out if I’m doing something wrong or whether this is a limitation of TS.

Submitted by D. Pelsmaeker on 10 September 2014 at 18:17

On 11 September 2014 at 11:24 D. Pelsmaeker commented:

The issue was a mistake on my part, I was looking at the whole thing wrong. It can be closed.


On 11 September 2014 at 18:53 Gabriël Konat closed this issue.

Log in to post comments