Limited access to `super` in conditional field name
- Dominant language
- Jsonnet
- Stars
- 7.6k
- Forks
- 475
- PR merge metrics
- No merged PRs in 30d
Description
This may just be a request for clarification, or else a bug/enhancement depending on the wisdom of jsonnet devs.
Currently it's not allowed to do this:
{} + {
[if 'spec' in super then 'spec']+: {
// overrides here
}
}
I think I understand why access to `self` and object locals is forbidden in field expressions like the above, but it seems to me that checking for existence `in super` would not cause any problems.
I have seen some discussions about similar code using `self` or about attempting to iterate `super` in a comprehension; what I'm looking for is a clear yes or no about whether it should be possible to do exactly what is written above.
The goal here is to write smart mixins that can alter the object on the left side of `+` without adding fields that should not be present. The workarounds are (imo) messy. Thanks for your consideration!
Contributor guide
Assessment
This issue has not been assessed yet.