scripts/image-fixes/20-OCProgramNodeTest.stOCAssignmentNode>>bestNodeFor:, OCProgramNodeTest>>testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPartThe test selects the interval ' := 1' in 'a := 1111111111111111.'. The interval does not touch the variable, so OCProgramNode>>bestNodeFor: found one intersecting child (the literal) and answered the literal. The test expected the assignment. The defect is in image code, not in either VM. The fix adds OCAssignmentNode>>bestNodeFor:. It calls super, and when the answer is the assignment's value and the interval starts after the assignment start but before the value start, it answers the assignment. The expectedFailure pragma is removed from the test; the assertions are unchanged. A first attempt that changed OCProgramNode>>bestNodeFor: for all node types broke testBestNodeFirstTempsAndFirstCommentGivesVariableNode, so I narrowed the fix to the assignment node.
| Test | Defect in | State | Cause |
|---|---|---|---|
OCProgramNodeTest>>testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart |
image-code | repaired | OCProgramNode>>bestNodeFor: answered the only intersecting child (the literal) when the interval covered the ' := ' text of the assignment |
Regression check: Each class was run without the fix (base image) and with the fix, on both ours and cog; pass counts did not drop. With the final fix on both VMs: OCProgramNodeTest 120 PASS + 1 FAIL before, 121 PASS after. OCMethodNodeTest 31 PASS before and after. OCParseCodeSnippetTest 4 PASS before and after. OCParserTest 147 PASS, 1 ERROR (testParseExpressionDontFreeze), 1 SKIP (testUnclosedTemporariesErrorNodeContainsRightValue) before and after; those two belong to another cluster. RubSmalltalkEditorTest 62 PASS before and after. RBSplitCascadeRefactoringTest, RBAddTemporaryVariableTransformationTest, ClyMethodCodeEditorToolMorphTest and OCAssignmentNodeTest are not in the image (MISSING-CLASS). The base-image runs of the first attempt covered all classes except OCAssignmentNodeTest; the final fix was rerun on all except the three missing refactoring/Calypso classes.
Upstream note: Pharo AST-Core: OCAssignmentNode>>bestNodeFor: answers the assignment when the selection lies in the ' := ' part. Selecting between the variable and the value of an assignment returned the value literal. The new method calls super, and when the result is the value and the interval starts after the assignment start but before the value start, it answers the assignment. This repairs OCProgramNodeTest>>testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart; the expectedFailure pragma is removed. Not submitted anywhere; needs owner review.
Last full sweeps of 2026-11-17: iospharo (sweep14-new14) and stock Cog with the Cog changes (sweepcogp14-new10), with all image fixes. "Before" is the state of the test before the repairs. The Stock Cog column has a value only where the record measured stock Cog: "PASS 3 of 3 (repair run)" is the check of each repair on stock Cog v12.0.6 with the fix entry; "-" is not measured separately.
| Test | Before | State | iospharo VM | Patched Cog | Stock Cog |
|---|---|---|---|---|---|
OCProgramNodeTest>>testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart | XFAIL | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
Run the tests in a Pharo 14 image (build 791). Before the fix they skip, fail or carry the expected-failure mark.
"Run in a Playground of a Pharo 14 image (Do it and print each line)." ((OCProgramNodeTest selector: #testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart) run) printString.
testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart <expectedFailure> "This tests shows that when the selection is not close to variable but to the colon the assignment is not returned but a literal (the righ value)" | ast start body | body := 'm | a | a := 1111111111111111. '. start := 'm | a | ' size. ast := (OCParser parseMethod: body) bestNodeFor: (start + 2 to: start + 6). self assert: ast isAssignment. self assert: ast sourceCode equals: 'a := 1111111111111111'.
How to apply an entries file: file in 00-header.st and the entries file as one chunk (the iospharo script scripts/gen-image-fixes.py makes that chunk). Each entry checks for the defect first and prints FIXED, ADDED or SKIP. Download 00-header.st.
"OCAssignmentNode>>bestNodeFor: answered the value (the right side) when the interval starts in the ' := ' between the variable and the value, because the value is the only child the interval touches. The interval lies in the assignment, so the assignment is the best node." add value: #OCAssignmentNode value: #bestNodeFor: value: 'querying' value: 'bestNodeFor: anInterval | node | node := super bestNodeFor: anInterval. ^ (node == value and: [ anInterval first >= self start and: [ anInterval first < value start ] ]) ifTrue: [ self ] ifFalse: [ node ]'. fix value: #OCProgramNodeTest value: #testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart value: [ :source | source includesSubstring: '<expectedFailure>' ] value: 'testBestNodeForReturnAStatementWhenIntervalInStatementWithoutLeftPart "When the selection is not close to the variable but to the colon, the assignment is returned, not the literal (the right value)" | ast start body | body := ''m | a | a := 1111111111111111. ''. start := ''m | a | '' size. ast := (OCParser parseMethod: body) bestNodeFor: (start + 2 to: start + 6). self assert: ast isAssignment. self assert: ast sourceCode equals: ''a := 1111111111111111''.'.
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.