chuck icon indicating copy to clipboard operation
chuck copied to clipboard

Static dur field not static

Open heuermh opened this issue 6 years ago • 1 comments

I believe this may already be a known issue; it appears static dur fields are not statically initialized

class Impatient
{
  1::ms => static dur moment;

 fun static void pause()
 {
    <<<"just a moment...", moment>>>;
  }
}

Impatient.pause();

reports

$ chuck impatient.ck 
just a moment... 0.000000

instead of the desired

$ chuck impatient.ck 
just a moment... 44.100000

See also

https://github.com/heuermh/lick/blob/master/Loops.ck#L26

Migrated from https://github.com/spencersalazar/chuck/issues/40

heuermh avatar Jan 16 '18 17:01 heuermh

reviving this long-standing issue...

possible remedy: static variables needs to be initialized separated and automatically; to start, may need limit the kinds of initialization (literals/decls only, no vars or functions, possible new and expressions with literals only)

gewang avatar Oct 08 '23 06:10 gewang