fix(format): guard against null members in FormatJvmModelInferrer.inferConstants#1474
Draft
joaodinissf wants to merge 1 commit into
Draft
fix(format): guard against null members in FormatJvmModelInferrer.inferConstants#1474joaodinissf wants to merge 1 commit into
joaodinissf wants to merge 1 commit into
Conversation
…erConstants inferConstants added createConstant(format, c) to the JVM model unconditionally. createConstant returns null for a value-less constant (its switch fall-through), so a null JvmMember reached it.getMembers().add(...) — which the EMF EList rejects with IllegalArgumentException: The 'no null' constraint is violated (or leaks a null member downstream). Regression class: the original Xtend `members += allConstants.map[createConstant]` compiled to JvmTypesBuilder.operator_add, which silently skips nulls; the Xtend-to-Java migration translated it to a bare loop-add that does not. Guard the add (equivalent to operator_add's null-skip). Add FormatJvmModelInferrerTest pinning the behaviour: a value-less constant must not produce a null member or throw. A/B verified — the test fails on the pre-fix code (no null constraint violated) and passes with the guard. Found by an archaeology audit of the merged Xtend→Java migrations; the skill rule that prevents this class is added separately (rules/10 §10.5). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
FormatJvmModelInferrer.inferConstantsaddscreateConstant(format, c)to the inferred JVM model unconditionally:createConstantreturnsnullfor a value-less constant (itsif (stringValue) … else if (intValue) … return nullfall-through — reachable for a constant in an incomplete/error state during editing). Adding that null to theJvmMemberEListthrowsIllegalArgumentException: The 'no null' constraint is violated.Root cause — a migration regression
The original Xtend was
members += allConstants.map[createConstant], which compiles toJvmTypesBuilder.operator_add, andoperator_addsilently skips null elements. The Xtend→Java migration translated+=to a bare loop-add, which does not skip nulls — so the null-skip semantics were lost. The siblinginferRulesin the same file kept the null-skip, making this an inconsistent one-off.The fix
Guard the add (equivalent to
operator_add's null-skip / anIterableExtensions.filterNull):Verification
FormatJvmModelInferrerTestpins the behaviour: a value-lessConstantmust not yield a null member or throw.IllegalArgumentException: The 'no null' constraint is violated) and passes with the guard. Full local gate: BUILD SUCCESS, 359 tests / 0 failures, all static analysis clean.Found by an archaeology audit of the merged Xtend→Java migrations. The skill rule that prevents this class of defect is added in a separate PR (#1473,
rules/10 §10.5—operator_addskips nulls).🤖 Generated with Claude Code