ccrma / chuck

ChucK Music Programming Language
http://chuck.stanford.edu/
GNU General Public License v2.0
803 stars 128 forks source link

string add-assign `"foo" +=> string s;` causes crash (bus error) #362

Closed gewang closed 1 year ago

gewang commented 1 year ago

possible location of issue Chuck_Instr_Add_string_Assign::execute()

gewang commented 1 year ago

more info: likely caused by add-assign to a string variable declaration

this works:

string foo;
"foo" +=> foo;

this crashes:

"foo" +=> string foo;
gewang commented 1 year ago

this raised the issue of whether add-assign to variable declarations should be allowed in the first place; after conferring with @nshaheed @spencersalazar, we decided to disallow this at the compilation stage (pushed in b997f80)

a.ck:1:7: error: cannot perform '+=>' on a variable declaration...
[1] "foo" +=> string s;
          ^
a.ck: ...(hint: use '=>' instead to initialize the variable)