google / google/go-jsonnet

Better error on mismatched binary operator

Open
#396 1 comment 0 reactions 0 assignees View on GitHub
error reporting
Dominant language
Go
Stars
1.8k
Forks
263
PR merge metrics
No merged PRs in 30d

Description

Consider this invalid snippet:

```jsonnet
{
abc: null
} + {
abc+: {
foo: "bar"
}
}
```

First, surprised me that it is invalid after all, because I assumed I could add `object` and `null` (which is represents "nothing", right?).

More importantly, the error message printed by `go-jsonnet` is pretty useless:
```
RUNTIME ERROR: Unexpected type null
During manifestation
```

While the one of `c++-jsonnet` is much better:
```
RUNTIME ERROR: binary operator + requires matching types, got null and object.
test.jsonnet:(3:5)-(7:2) object
During manifestation
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.