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

Magic comment "immutable: string" makes "literal".freeze the default for that file #487

Closed
wants to merge 4 commits into
base: trunk
from
Jump to file or symbol
Failed to load files and symbols.
+7 −5
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Fix issue with empty strings resulting in a call to NilClass#freeze

  • Loading branch information...
jroesch committed Dec 27, 2013
commit 7b190a64222a23a6ca4aa8172901427ff82fbecc
View
12 parse.y
@@ -3817,6 +3817,11 @@ strings : string
else {
node = evstr2dstr(node);
}
if (parser->immutable_strings) {
node = NEW_CALL(node, idFreeze, 0);
}
$$ = node;
/*%
$$ = $1;
@@ -3839,12 +3844,9 @@ string : tCHAR
string1 : tSTRING_BEG string_contents tSTRING_END
{
/*%%%*/
$$ = $2;
if (parser->immutable_strings) {
$$ = NEW_CALL($2, idFreeze, 0);
} else {
$$ = $2;
}
/*%
$$ = dispatch1(string_literal, $2);
%*/
ProTip! Use n and p to navigate between commits in a pull request.