From b40b10826cca0a57104f21bc551664d5eeab1c07 Mon Sep 17 00:00:00 2001 From: Kampfkarren Date: Tue, 26 Jul 2022 18:40:47 -0700 Subject: [PATCH] Fix constant folding --- Compiler/src/ConstantFolding.cpp | 2 ++ tests/conformance/stringinterp.lua | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Compiler/src/ConstantFolding.cpp b/Compiler/src/ConstantFolding.cpp index f6f98675..7c119b16 100644 --- a/Compiler/src/ConstantFolding.cpp +++ b/Compiler/src/ConstantFolding.cpp @@ -353,6 +353,8 @@ struct ConstantVisitor : AstVisitor { // INTERP CODE REVIEW: This can theoretically fold something like `debug mode: {DEBUG_MODE}` where DEBUG_MODE is true. // Is this necessary or just something we can do later? + for (AstExpr* expression : interpString->expressions) + analyze(expression); } else { diff --git a/tests/conformance/stringinterp.lua b/tests/conformance/stringinterp.lua index e691ed96..8ffe78b8 100644 --- a/tests/conformance/stringinterp.lua +++ b/tests/conformance/stringinterp.lua @@ -21,10 +21,10 @@ assertEq(`true = {true}`, "true = true") -- -- INTERP TODO: Syntax error -- -- assert(string.find(`{{ "nested braces!" }}`, "table")) --- local name = "Luau" --- assertEq(`Welcome to { --- name --- }!`, "Welcome to Luau!") +local name = "Luau" +assertEq(`Welcome to { + name +}!`, "Welcome to Luau!") local nameNotConstantEvaluated = (function() return "Luau" end)() assertEq(`Welcome to {nameNotConstantEvaluated}!`, "Welcome to Luau!")