diff --git a/src/kinds.jl b/src/kinds.jl index 6dcc3557..94ed12c4 100644 --- a/src/kinds.jl +++ b/src/kinds.jl @@ -887,6 +887,7 @@ const _kind_names = "inert" # QuoteNode; not quasiquote "juxtapose" # Numeric juxtaposition like 2x "string" # A string interior node (possibly containing interpolations) + "format" # String formatting specification "cmdstring" # A cmd string node (containing delimiters plus string) "char" # A char string node (containing delims + char data) "macrocall" diff --git a/src/parser.jl b/src/parser.jl index 675ac34c..03e2dfc4 100644 --- a/src/parser.jl +++ b/src/parser.jl @@ -3182,14 +3182,16 @@ function parse_string(ps::ParseState, raw::Bool) m = position(ps) bump(ps, TRIVIA_FLAG) opts = parse_brackets(ps, K")") do had_commas, had_splat, num_semis, num_subexprs - return (needs_parameters=false, + return (needs_parameters=true, simple_interp=!had_commas && num_semis == 0 && num_subexprs == 1) end if !opts.simple_interp || peek_behind(ps, skip_parens=false).kind == K"generator" # "$(x,y)" ==> (string (parens (error x y))) - emit(ps, m, K"error", error="invalid interpolation syntax") + emit(ps, m, K"format") + min_supported_version(v"1.10", ps, m, "string formatting syntax") + else + emit(ps, m, K"parens") end - emit(ps, m, K"parens") elseif k == K"var" # var identifiers disabled in strings # "$var" ==> (string var)