Ticket #1381
Greetings. Seems there's something can remain uninitialized in static fields when running in Javascript. If we have
@Js class A { const static B myB := B.def } @Js const class B { const static B def := B() Str foo() { "foo" } }
And do somewhere a button
Button { text = "foo" onAction.add |Event e| { try { Dialog.openInfo(e.window, A.myB.foo) } catch (Err err) { Dialog.openErr(e.window, err.traceToStr) } } }
Then we'll get a "A.m_myB is null" on click error in Javascript.
Renamed from const static fields problem in Javascript to js: Static init dependency order bug
Promoted to ticket #1381 and assigned to andy
Yes - there appears to be a dependency order bug with static field definition. Swapping the definition of A and B worked for me.
A
B
Login or Signup to reply.
ilya Wed 12 Jan 2011
Greetings. Seems there's something can remain uninitialized in static fields when running in Javascript. If we have
And do somewhere a button
Then we'll get a "A.m_myB is null" on click error in Javascript.
andy Wed 12 Jan 2011
Renamed from const static fields problem in Javascript to js: Static init dependency order bug
andy Wed 12 Jan 2011
Promoted to ticket #1381 and assigned to andy
Yes - there appears to be a dependency order bug with static field definition. Swapping the definition of
A
andB
worked for me.