Fix constant folding

This commit is contained in:
Kampfkarren 2022-07-26 18:40:47 -07:00
parent da716a6a76
commit b40b10826c
2 changed files with 6 additions and 4 deletions

View file

@ -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
{

View file

@ -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!")