#1381 js: Static init dependency order bug

ilya Wed 12 Jan 2011

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.

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 and B worked for me.

Login or Signup to reply.