possible error in spec

35 views
Skip to first unread message

Sophia Roshal

unread,
Jul 20, 2023, 12:39:50 AM7/20/23
to Jsonnet
Hello! 
For the object merge operator, I believe that there might be an error in the specification. currently, it seems like the spec says that only the fields that have the same name as the super object have super substituted for the LHS object (with the proper modifications for multiple inheritance). However, shouldn't all fields have this substitution performed so that super correctly references the super object? It also seems like the implementation does do this, and this is purely an error in the specification. 

Dave Cunningham

unread,
Aug 14, 2023, 7:01:14 AM8/14/23
to Sophia Roshal, Jsonnet
Can you give an example of code that behaves differently to what the spec says?

In general `super` is static in the sense of direct field accesses, although when you're executing code in the expressions of those field, self is bound to the original derived object.  That is the expected semantics of object orientation and it was tricky to represent it correctly in the semantics.

```
dcunnin@dcunnin:~$ jsonnet -e '{ f: 1, g: 2, x: self.f} + { f: 10, g: 20, x: self.g, y: super.x}'
{
   "f": 10,
   "g": 20,
   "x": 20,
   "y": 10
}
```

On Thu, 20 Jul 2023 at 05:39, 'Sophia Roshal' via Jsonnet <jso...@googlegroups.com> wrote:
Hello! 
For the object merge operator, I believe that there might be an error in the specification. currently, it seems like the spec says that only the fields that have the same name as the super object have super substituted for the LHS object (with the proper modifications for multiple inheritance). However, shouldn't all fields have this substitution performed so that super correctly references the super object? It also seems like the implementation does do this, and this is purely an error in the specification. 

--
You received this message because you are subscribed to the Google Groups "Jsonnet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonnet+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsonnet/0a4b93a1-3478-4f1c-b8e7-0c068fbf2e28n%40googlegroups.com.

Sophia Roshal

unread,
Aug 14, 2023, 12:04:40 PM8/14/23
to Dave Cunningham, Jsonnet
Hi Dave,
Yes, I've attached an example of where I think the spec is not entirely correct.
The spec as it stands would only do the substitution in e_s/super in x and y (since that is the overlapping fields eR_1-eR_m), however, I believe the substitution should also be applied to eR_1'-eR_p'. 
Thanks!
Sophia
possible_bug.jpeg
Reply all
Reply to author
Forward
0 new messages