about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-16T22·57+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-16T22·57+0200
commitb8034e5581ef40cc043da35ed01280b166da81ca (patch)
tree68f06d5eeebba28cbcd5f6a882c0c168c985b74a /src
parent9d8a80375d2d0581b53d270eb4d543fa0d3f0190 (diff)
Ensure proper type checking/coercion of "${expr}"
Now we only rewrite "${expr}" to expr if expr is a string literal.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/parser.y5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index dab71546f108..b4f72e599b66 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -203,7 +203,8 @@ static Expr * stripIndentation(SymbolTable & symbols, vector<Expr *> & es)
         es2->push_back(new ExprString(symbols.create(s2)));
     }
 
-    return es2->size() == 1 ? (*es2)[0] : new ExprConcatStrings(true, es2);
+    /* If this is a single string, then don't do a concatenation. */
+    return es2->size() == 1 && dynamic_cast<ExprString *>((*es2)[0]) ? (*es2)[0] : new ExprConcatStrings(true, es2);
 }
 
 
@@ -359,7 +360,7 @@ expr_simple
   | '"' string_parts '"' {
       /* For efficiency, and to simplify parse trees a bit. */
       if ($2->empty()) $$ = new ExprString(data->symbols.create(""));
-      else if ($2->size() == 1) $$ = $2->front();
+      else if ($2->size() == 1 && dynamic_cast<ExprString *>($2->front())) $$ = $2->front();
       else $$ = new ExprConcatStrings(true, $2);
   }
   | IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE {