mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Fix more complicated case
This commit is contained in:
parent
9ea7b44ab9
commit
da716a6a76
2 changed files with 16 additions and 9 deletions
|
@ -1509,18 +1509,19 @@ struct Compiler
|
|||
if (formatStringIndex < 0)
|
||||
CompileError::raise(expr->location, "Exceeded constant limit; simplify the code to compile");
|
||||
|
||||
|
||||
bytecode.emitABC(LOP_LOADK, target, formatStringIndex, 0);
|
||||
|
||||
// INTERP CODE REVIEW: Why do I need this?
|
||||
// If I don't, it emits `LOADK R1 K1` instead of `LOADK R2 K1`,
|
||||
// and it gives the error "missing argument 2".
|
||||
allocReg(expr, 1);
|
||||
|
||||
RegScope rs(this);
|
||||
// bytecode.emitABC(LOP_LOADK, target, formatStringIndex, 0);
|
||||
emitLoadK(target, formatStringIndex);
|
||||
|
||||
for (AstExpr* expression : expr->expressions)
|
||||
compileExprAuto(expression, rs);
|
||||
{
|
||||
uint8_t reg = allocReg(expression, 1);
|
||||
compileExpr(expression, reg, targetTemp);
|
||||
}
|
||||
|
||||
BytecodeBuilder::StringRef formatMethod = sref(AstName("format"));
|
||||
|
||||
|
|
|
@ -22,11 +22,17 @@ assertEq(`true = {true}`, "true = true")
|
|||
-- -- assert(string.find(`{{ "nested braces!" }}`, "table"))
|
||||
|
||||
-- local name = "Luau"
|
||||
-- assert(`Welcome to {
|
||||
-- assertEq(`Welcome to {
|
||||
-- name
|
||||
-- }!` == "Welcome to Luau!")
|
||||
-- assert(`Welcome to \
|
||||
-- {name}!` == "Welcome to\nLuau!")
|
||||
-- }!`, "Welcome to Luau!")
|
||||
|
||||
local nameNotConstantEvaluated = (function() return "Luau" end)()
|
||||
assertEq(`Welcome to {nameNotConstantEvaluated}!`, "Welcome to Luau!")
|
||||
|
||||
-- assertEq(`This {local} does not exist`, "This nil does not exist")
|
||||
|
||||
-- assertEq(`Welcome to \
|
||||
-- {name}!`, "Welcome to\nLuau!")
|
||||
|
||||
-- assert(`Escaped brace: \{} ({1})` == "Escaped brace: { (1)")
|
||||
-- assert(`Backslash \ that escapes the space is not a part of the string... ({2})` == "Backslash that escapes the space is not a part of the string... (2)")
|
||||
|
|
Loading…
Add table
Reference in a new issue