[ruby/prism] Make xstrings concat syntax error
https://github.com/ruby/prism/commit/f734350499
This commit is contained in:
parent
f69ad0e810
commit
3d6fc29169
@ -3140,6 +3140,7 @@ nodes:
|
|||||||
- EmbeddedStatementsNode
|
- EmbeddedStatementsNode
|
||||||
- EmbeddedVariableNode
|
- EmbeddedVariableNode
|
||||||
- InterpolatedStringNode # `"a" "#{b}"`
|
- InterpolatedStringNode # `"a" "#{b}"`
|
||||||
|
- on error: XStringNode # `<<`FOO` "bar"
|
||||||
- name: closing_loc
|
- name: closing_loc
|
||||||
type: location?
|
type: location?
|
||||||
newline: parts
|
newline: parts
|
||||||
|
@ -5328,6 +5328,12 @@ pm_interpolated_string_node_append(pm_interpolated_string_node_t *node, pm_node_
|
|||||||
// should clear the mutability flags.
|
// should clear the mutability flags.
|
||||||
CLEAR_FLAGS(node);
|
CLEAR_FLAGS(node);
|
||||||
break;
|
break;
|
||||||
|
case PM_X_STRING_NODE:
|
||||||
|
case PM_INTERPOLATED_X_STRING_NODE:
|
||||||
|
// If this is an x string, then this is a syntax error. But we want
|
||||||
|
// to handle it here so that we don't fail the assertion.
|
||||||
|
CLEAR_FLAGS(node);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false && "unexpected node type");
|
assert(false && "unexpected node type");
|
||||||
break;
|
break;
|
||||||
@ -16823,6 +16829,10 @@ parse_strings(pm_parser_t *parser, pm_node_t *current, bool accepts_label, uint1
|
|||||||
// If we haven't already created our container for concatenation,
|
// If we haven't already created our container for concatenation,
|
||||||
// we'll do that now.
|
// we'll do that now.
|
||||||
if (!concating) {
|
if (!concating) {
|
||||||
|
if (!PM_NODE_TYPE_P(current, PM_STRING_NODE) && !PM_NODE_TYPE_P(current, PM_INTERPOLATED_STRING_NODE)) {
|
||||||
|
pm_parser_err_node(parser, current, PM_ERR_STRING_CONCATENATION);
|
||||||
|
}
|
||||||
|
|
||||||
concating = true;
|
concating = true;
|
||||||
pm_token_t bounds = not_provided(parser);
|
pm_token_t bounds = not_provided(parser);
|
||||||
|
|
||||||
|
5
test/prism/errors/xstring_concat.txt
Normal file
5
test/prism/errors/xstring_concat.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<<`EOC` "bar"
|
||||||
|
^~~~~~~ expected a string for concatenation
|
||||||
|
echo foo
|
||||||
|
EOC
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user