Go implementation differs from C++ implementation when overriding the std binding and invoking an operator that desugars to a std library call.
For example with
local std = {}; 1 == 1
which would desugar to
local std = /* std.jsonnet */; local std = {}; std.equals(1, 1)
The C++ implementation fails:
RUNTIME ERROR: field does not exist: equals
while the Go implementation prints true.
To me, the Go behavior makes for sense than the C++ one, since breaking syntax constructs by overriding a binding seems weird. However, the C++ behavior is closer to what the "Desugaring" section of the specification mandates.
The Go implementation behaves as if it desugared to something like
local std = /* std.jsonnet */; local std = {}; (/* std.jsonnet */).equals(1, 1)
I think it would be nice to have consistent behavior across implementations, and have such behavior written in the specification.
The optimisations that replace std functions with their native equivalents need to be aware that std has been redefined, which shouldn't be too hard to implement.
Go implementation differs from C++ implementation when overriding the
std
binding and invoking an operator that desugars to astd
library call.For example with
which would desugar to
The C++ implementation fails:
while the Go implementation prints
true
.To me, the Go behavior makes for sense than the C++ one, since breaking syntax constructs by overriding a binding seems weird. However, the C++ behavior is closer to what the "Desugaring" section of the specification mandates.
The Go implementation behaves as if it desugared to something like
I think it would be nice to have consistent behavior across implementations, and have such behavior written in the specification.