Skip to content

fix: error on super[key] when there is no superclass#911

Open
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/super-lookup-no-superclass
Open

fix: error on super[key] when there is no superclass#911
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/super-lookup-no-superclass

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix visitLookupSuper (super[key]) to error when there is no superclass, matching the existing visitSelectSuper (super.name) behavior.

Motivation

visitLookupSuper (super[key]) silently fell back to self when no superclass existed, while visitSelectSuper (super.name) correctly reported "Attempt to use \super` when there is no super class"`. This inconsistency could mask bugs in Jsonnet programs and diverged from go-jsonnet and jrsonnet which both error in this case.

Modification

Replace the silent sup = self fallback in visitLookupSuper with the same error that visitSelectSuper uses. Change var sup to val sup since it is no longer reassigned.

Result

super[key] and super.name now behave identically when there is no superclass, both reporting the same error. This matches go-jsonnet and jrsonnet semantics.

Test plan

  • All 143 existing test suites pass
  • Formatting clean

Motivation:
visitLookupSuper (super[key]) silently fell back to self when no
superclass existed, while visitSelectSuper (super.name) correctly
reported "Attempt to use `super` when there is no super class".
This inconsistency could mask bugs in Jsonnet programs and diverged
from go-jsonnet and jrsonnet which both error in this case.

Modification:
Replace the silent `sup = self` fallback in visitLookupSuper with
the same error that visitSelectSuper uses. Change `var sup` to
`val sup` since it is no longer reassigned.

Result:
super[key] and super.name now behave identically when there is no
superclass, both reporting the same error. This matches go-jsonnet
and jrsonnet semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant