supercollider / supercollider

An audio server, programming language, and IDE for sound synthesis and algorithmic composition.
http://supercollider.github.io
GNU General Public License v3.0
5.52k stars 750 forks source link

Broken bytecode emission #5931

Closed LookMumNoBackup closed 1 year ago

LookMumNoBackup commented 1 year ago

Environment

Steps to reproduce

(
g = { arg a, b; ^(a + b) };
g.def.dumpByteCodes;
g.value(5,10);
)

Receive following output in post window

BYTECODES: (6)
  0   30         PushTempZeroVar 'a'
  1   31         PushTempZeroVar 'b'
  2   FF       TailCallReturnFromMethod
  3   E0       SendSpecialBinaryArithMsg '+'
  4   F3       Return
  5   F2       BlockReturn

Expected vs. actual behavior

Expected

Option (1): 15 is printed out in the post window after byte-code dump. Option (2): Syntax error as ^ seems to be not allowed in this context. Option (3): Exception thrown at runtime, that something is wrong with the function.

Actual

Neither the result is printed, nor any kind of error thrown. Any further code in the same region seems to be silently ommited. E.g. following code do not change the output in the post window after clearing:

(
g = { arg a, b; ^(a + b) };
g.def.dumpByteCodes;
g.value(5,10);
10.value;
)

Note: I am just starting to getting warm with SC and though do not speak this language fluently. Somehow I though after looking at different class definitions that the ^ symbol syntactically means return. Now it seems to me that it is only valid in class definitions. Please correct me if I am wrong.

dyfer commented 1 year ago

Now it seems to me that it is only valid in class definitions.

Yes, that is correct.

LookMumNoBackup commented 1 year ago

@dyfer Thanks for the fast feedback. I think this behaviour is at least worth being documented, if fixing is too cumbersome. If I get a hint where to place this information and which branch to use, I can create a corresponding pull request.

dyfer commented 1 year ago

Yes, it is certainly worth being documented. I was sure it was, but indeed I can't find it.

I think it would be worth mentioning it in one or all of:

Also I found https://github.com/supercollider/supercollider/issues/2674 - this PR could be consider its duplicate, in a way. But feel free to keep it open until the documentation fix is submitted.

Here's another discussion touching on the use of ^: https://github.com/supercollider/supercollider/issues/4822

As for the branch, feel free to submit it on 3.13, so that we can include it in the upcoming release (candidate). Thanks!

LookMumNoBackup commented 1 year ago

@dyfer Many thanks for all the information. Highly appreciated! I am not sure if I will be able to contribute this year, but will definitely do it asap.

The issue #2674 seems to be a duplicate. There is no need to keep this issue opened. In case of later contribution I will use #2674 as reference.