Given:
module Statics {
var ok as Boolean = false;
class C {
function initialize() {
C.foo();
}
static function bar() as Void {
C.foo();
}
private static function foo() as Void {
ok = true;
}
}
(:test)
function static_from_initialize(logger as Logger) as Boolean {
ok = false;
var c = new C();
return ok;
}
(:test)
function static_from_static(logger as Logger) as Boolean {
ok = false;
C.bar();
return ok;
}
}
The code compiles and works as expected with sdk-4.1.5 and earlier (ie C.foo() is successfully called, both from C.initialize() and from C.bar()),
With sdk-4.1.6 the type checker is happy (it compiles with Strict type checking), but fails at runtime with:
Executing test Statics.static_from_initialize... Error: Symbol Not Found Error Details: Could not find symbol 'foo' Stack: - initialize() at /Users/mwilliams/www/git/monkeyc-optimizer/test/OptimizerTests/source/OptimizerTestsLookup.mc:288 0x10003151 - static_from_initialize() at /Users/mwilliams/www/git/monkeyc-optimizer/test/OptimizerTests/source/OptimizerTestsLookup.mc:302 0x10003181 - evaluate_test_entries_30_to_39() at UnitTests.mc:182 0x10001bc6 - runTest() at UnitTests.mc:215 0x10001d92 ERROR ------------------------------------------------------------------------------ Executing test Statics.static_from_static... Error: Symbol Not Found Error Details: Could not find symbol 'foo' Stack: - bar() at /Users/mwilliams/www/git/monkeyc-optimizer/test/OptimizerTests/source/OptimizerTestsLookup.mc:291 0x1000312f - static_from_static() at /Users/mwilliams/www/git/monkeyc-optimizer/test/OptimizerTests/source/OptimizerTestsLookup.mc:308 0x100031b2 - evaluate_test_entries_30_to_39() at UnitTests.mc:185 0x10001bed - runTest() at UnitTests.mc:215 0x10001d92 ERROR
I caught this building the Meditate folder in the open source project https://github.com/vtrifonov-esfiddle/Meditate . The built project runs correctly with 4.1.5 and earlier, but fails when you hit the start button with 4.1.6.
It also looks like the 4.2.0-beta sdk has the same issue - and in fact it seems to be another compiler2 vs compiler1 issue, because compiling with 4.1.6 or 4.2.0-beta at -O0 fixes the problem.
EDIT:
The bug only affects private and protected references. And if I look at the output with -g, I see this with from sdk-4.1.5:
lgetv 0
spush C
getv
spush <globals/Statics/C/<>foo>
getv
frpush
invokem 1
popv
But this from sdk-4.1.6
lgetv 0
spush C
getv
spush foo
getv
frpush
invokem 1
popv
So 4.1.5 is correctly pushing the "private" symbol for foo, while 4.1.6 is incorrectly pushing the public symbol.
Also, if I make foo protected, instead of private, and create a class D which extends C, and have that try to call C.foo, it fails the same way with 4.1.6 AND 4.1.5 (but again, the type checker is happy with both compiler versions).
-
markw65
-
Cancel
-
Vote Up
0
Vote Down
-
-
More
-
Cancel
Comment-
markw65
-
Cancel
-
Vote Up
0
Vote Down
-
-
More
-
Cancel
Children