string interpolation: don't trust type checking, only start from strings if they're literals
This commit is contained in:
parent
52ec0c3b1d
commit
ae0651127d
|
@ -447,8 +447,12 @@ pub(crate) fn compile_expression(
|
||||||
Expr::StringInterpolation(exprs) | Expr::GlobInterpolation(exprs, _) => {
|
Expr::StringInterpolation(exprs) | Expr::GlobInterpolation(exprs, _) => {
|
||||||
let mut exprs_iter = exprs.iter().peekable();
|
let mut exprs_iter = exprs.iter().peekable();
|
||||||
|
|
||||||
if exprs_iter.peek().is_some_and(|e| e.ty == Type::String) {
|
if exprs_iter
|
||||||
// If the first expression is typed as a string, just take it and build from that
|
.peek()
|
||||||
|
.is_some_and(|e| matches!(e.expr, Expr::String(..) | Expr::RawString(..)))
|
||||||
|
{
|
||||||
|
// If the first expression is a string or raw string literal, just take it and build
|
||||||
|
// from that
|
||||||
compile_expression(
|
compile_expression(
|
||||||
working_set,
|
working_set,
|
||||||
builder,
|
builder,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user