scripts/image-fixes/20-St-evaluate-declare-global.stStObjectContextPresenterTest>>testDoEvaluateDeclareGlobal, StPlaygroundPagePresenterTest>>testDoEvaluateDeclareGlobal, OCCodeReparator>>openMenuBoth tests skipped themselves because they relied on catching OCUndeclaredVariableWarning and sending it declareGlobal. That warning is signalled only when the compiler has permitUndeclared set, and it has no declareGlobal method now (declareGlobal lives on OCCodeReparator). The presenters compile with the interaction model as requestor, so an undeclared uppercase variable goes through OCCodeReparator>>openMenu, which has no entry that declares a global. OCCodeReparator>>declareGlobal was unreachable from the UI, and only OCCodeReparatorTest called it. Fix: (1) OCCodeReparator>>openMenu gets a menu entry 'Declare new global variable' that runs declareGlobal, for uppercase names. (2) Both tests lose the skip. They swap UIManager default for an anonymous subclass whose chooseFrom:lines:title: picks that entry, run doEvaluateAndGo, then restore the old manager in ensure:. They still assert value is nil and that the global exists afterwards. No assertion was weakened.
| Test | Defect in | State | Cause |
|---|---|---|---|
StObjectContextPresenterTest>>testDoEvaluateDeclareGlobal |
test | repaired | Test skipped itself on an obsolete hook (OCUndeclaredVariableWarning>>declareGlobal). The real path is the OCCodeReparator menu, which had no declare-global entry. The test now drives that menu through a stub UIManager, and the menu gets the entry. |
StPlaygroundPagePresenterTest>>testDoEvaluateDeclareGlobal |
test | repaired | Same as the other test; it keeps the selectionInterval 1 to: 16 step. |
Regression check: Ran on both VMs, base image vs fixed image. Our VM: StObjectContextPresenterTest 1 PASS + 1 SKIP before, 2 PASS after. StPlaygroundPagePresenterTest 13 PASS + 1 SKIP before, 14 PASS after. OCCodeReparatorTest 7 PASS before and after. OCInteraciveAPITest 2 PASS before and after. Cog gave the same numbers in every case. OCCodeReparatorTest and OCInteraciveAPITest cover openMenu, declareGlobal and the interactive API. I did not run other test classes.
Upstream note: Pharo (OpalCompiler-UI, NewTools/Spec2 tests): The test testDoEvaluateDeclareGlobal in StObjectContextPresenterTest and StPlaygroundPagePresenterTest has been skipped since the compiler API change. It hooked OCUndeclaredVariableWarning, which legacy interactive mode no longer signals. The proposal adds a 'Declare new global variable' entry to OCCodeReparator>>openMenu (declareGlobal exists but no UI path calls it) and rewrites the tests to answer the menu with a stub UIManager. Under review by the owner before any PR; none was made.
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 |
|---|---|---|---|---|---|
StObjectContextPresenterTest>>testDoEvaluateDeclareGlobal | SKIP | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
StPlaygroundPagePresenterTest>>testDoEvaluateDeclareGlobal | SKIP | 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)." ((StObjectContextPresenterTest selector: #testDoEvaluateDeclareGlobal) run) printString. ((StPlaygroundPagePresenterTest selector: #testDoEvaluateDeclareGlobal) run) printString.
testDoEvaluateDeclareGlobal | value | self skip: 'Because a change in the compiler API, there is no way to hijack OCUndeclaredVariableWarning when the compiler is used a in legacy interactive mode (but such hijack is only performed in this test). So disable the test for now.'. self deny: (Smalltalk globals includesKey: #MyGlobalForTest). self openInstance. presenter evaluator text: 'MyGlobalForTest'. presenter whenActivatedDo: [ :selection | value := selection value ]. [presenter doEvaluateAndGo] on: OCUndeclaredVariableWarning do: [ :warn | warn declareGlobal ]. self assert: value equals: nil. self assert: (Smalltalk globals includesKey: #MyGlobalForTest). Smalltalk globals removeKey: #MyGlobalForTest
testDoEvaluateDeclareGlobal | value | self skip: 'Because a change in the compiler API, there is no way to hijack OCUndeclaredVariableWarning when the compiler is used a in legacy interactive mode (but such hijack is only performed in this test). So disable the test for now.'. self deny: (Smalltalk globals includesKey: #MyGlobalForTest). self openInstance. presenter contents: 'MyGlobalForTest'. presenter whenActivatedDo: [ :selection | value := selection value ]. presenter text selectionInterval: (1 to: 16). [presenter doEvaluateAndGo] on: OCUndeclaredVariableWarning do: [ :warn | warn declareGlobal ]. self assert: value equals: nil. self assert: (Smalltalk globals includesKey: #MyGlobalForTest). Smalltalk globals removeKey: #MyGlobalForTest
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.
fix value: #StObjectContextPresenterTest value: #testDoEvaluateDeclareGlobal value: [ :s | s includesSubstring: 'self skip:' ] value: 'testDoEvaluateDeclareGlobal | value oldManager stubClass | self deny: (Smalltalk globals includesKey: #MyGlobalForTest). self openInstance. presenter evaluator text: ''MyGlobalForTest''. presenter whenActivatedDo: [ :selection | value := selection value ]. "The compiler offers to repair the undeclared variable with a menu (OCCodeReparator>>openMenu). Answer the entry that declares a global." oldManager := UIManager default. stubClass := oldManager class newAnonymousSubclass. stubClass compile: ''chooseFrom: labels lines: lines title: title ^ labels indexOf: ''''Declare new global variable'''' ifAbsent: [ 0 ]''. [ UIManager default: stubClass new. presenter doEvaluateAndGo ] ensure: [ UIManager default: oldManager ]. self assert: value equals: nil. self assert: (Smalltalk globals includesKey: #MyGlobalForTest). Smalltalk globals removeKey: #MyGlobalForTest'. fix value: #StPlaygroundPagePresenterTest value: #testDoEvaluateDeclareGlobal value: [ :s | s includesSubstring: 'self skip:' ] value: 'testDoEvaluateDeclareGlobal | value oldManager stubClass | self deny: (Smalltalk globals includesKey: #MyGlobalForTest). self openInstance. presenter contents: ''MyGlobalForTest''. presenter text selectionInterval: (1 to: 16). presenter whenActivatedDo: [ :selection | value := selection value ]. "The compiler offers to repair the undeclared variable with a menu (OCCodeReparator>>openMenu). Answer the entry that declares a global." oldManager := UIManager default. stubClass := oldManager class newAnonymousSubclass. stubClass compile: ''chooseFrom: labels lines: lines title: title ^ labels indexOf: ''''Declare new global variable'''' ifAbsent: [ 0 ]''. [ UIManager default: stubClass new. presenter doEvaluateAndGo ] ensure: [ UIManager default: oldManager ]. self assert: value equals: nil. self assert: (Smalltalk globals includesKey: #MyGlobalForTest). Smalltalk globals removeKey: #MyGlobalForTest'. fix value: #OCCodeReparator value: #openMenu value: [ :s | (s includesSubstring: 'declareGlobal') not and: [ s includesSubstring: 'labels add: ''Define new trait''.' ] ] value: ((OCCodeReparator includesSelector: #openMenu) ifTrue: [ (OCCodeReparator >> #openMenu) sourceCode copyReplaceAll: 'labels add: ''Define new trait''.' with: 'labels add: ''Declare new global variable''. actions add: [ self declareGlobal ]. labels add: ''Define new trait''.' ] ifFalse: [ '' ]).
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.