Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused by error: calling 'unison()' at this point skips initialization of a needed variable #348

Closed
heuermh opened this issue Aug 19, 2023 · 12 comments
Labels

Comments

@heuermh
Copy link
Contributor

heuermh commented Aug 19, 2023

I'm not able to figure out what the compiler is trying to tell me here, it used to work previous to ChucK version 1.5.1.0

$ chuck --loop &
$ chuck + import.ck
...
Chord.ck:30:15: error: calling 'unison()' at this point skips initialization of a needed variable:
[30]     Intervals.unison() @=> Interval unison;
                   ^
Chord.ck:30:31: error: ...(note: this skipped variable initialization is needed by 'fun Unison Intervals.unison()')
[30]     Intervals.unison() @=> Interval unison;
                                   ^
Chord.ck:47:11907: error: ...(note: this is where the variable is used within 'fun Unison Intervals.unison()' or its subsidiaries)
Chord.ck: ...(hint: try calling 'unison()' after the variable initialization)

Chord.ck https://github.com/heuermh/lick/blob/master/lick/interval/Chord.ck#L23
Intervals.ck https://github.com/heuermh/lick/blob/master/lick/interval/Intervals.ck#L26

I tried to create a small test case, but this works

$ cat Baz.ck
class Qux
{
  fun static Qux create()
  {
    Qux qux;
    return qux;
  }
}
class Baz
{
  Qux.create() @=> Qux qux;

  fun Qux sample()
  {
    return qux;
  }
}

$ chuck Baz.ck
@gewang
Copy link
Member

gewang commented Aug 20, 2023

This bug appears to be caused by the compiler not taking into account values/func/types created in a different file context and treating them as if they were part of the current file context. A fix has been pushed in fc1d609

@heuermh
Copy link
Contributor Author

heuermh commented Aug 20, 2023

Thanks! Will give it a shot

@gewang
Copy link
Member

gewang commented Aug 21, 2023

FYI encountering a crash on windows related to the newly added code, investigating...

@gewang
Copy link
Member

gewang commented Aug 21, 2023

crash remedy pushed ccb5af8; let us know if you run into any further funny business hah

@heuermh
Copy link
Contributor Author

heuermh commented Aug 21, 2023

Progress made, thank you!

Now on mac at commit 2295db4

[chuck]: (VM) sporking incoming shred: 188 (IntervalDurProvider.ck)...
Pattern.ck:33:9: error: not all control paths in 'fun int Pattern.size(int capacity)' return a value
[33]     fun int size(int capacity)
             ^
Segmentation fault: 11

Will continue to work through these . . .

@heuermh
Copy link
Contributor Author

heuermh commented Aug 21, 2023

After a few more fixes to LicK, I've only ccrma/chugins#70 left, and that is already being looked into. Thanks again!

@gewang
Copy link
Member

gewang commented Aug 21, 2023

Progress made, thank you!

Now on mac at commit 2295db4

[chuck]: (VM) sporking incoming shred: 188 (IntervalDurProvider.ck)...
Pattern.ck:33:9: error: not all control paths in 'fun int Pattern.size(int capacity)' return a value
[33]     fun int size(int capacity)
             ^
Segmentation fault: 11

Will continue to work through these . . .

Thanks Michael! Hmm, that segmentation fault is an issue; if you'd like, could you reproduce and send code? We should try to fix that!

@gewang
Copy link
Member

gewang commented Aug 21, 2023

update: I am able to repro the crash from LiCK main branch and running import.ck... enough to start investigating; will report back

@gewang
Copy link
Member

gewang commented Aug 21, 2023

located source of the segmentation fault; fix(hopefully!) pushed in bd8b168

@heuermh
Copy link
Contributor Author

heuermh commented Aug 21, 2023

Yes, after that commit, I confirm no more seg faults

@gewang
Copy link
Member

gewang commented Aug 21, 2023

FYI ran latest in tip of main of LiCK with success (macOS Ventura 13.5)

chuck import.ck test.ck
[...]
"ArrayListTest ok" :(string)
"ArraySetTest ok" :(string)
"GraphTest ok" :(string)
"GraphsTest ok" :(string)
"FloatArrayListTest ok" :(string)
"IntArrayListTest ok" :(string)
"InterpolationTest ok" :(string)
"LoopsTest ok" :(string)

@heuermh
Copy link
Contributor Author

heuermh commented Aug 23, 2023

Thank you, @gewang! Closing, fixed as of 1.5.1.1 release

@heuermh heuermh closed this as completed Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants