From bd258bd79af3f72f9d6cf92ac8bfb2eacb8bea06 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Sun, 30 Sep 2012 17:58:46 -0700 Subject: [PATCH] woops, don't crash on empty string --- moonscript/transform.lua | 2 +- moonscript/transform.moon | 2 +- tests/inputs/string.moon | 1 + tests/outputs/string.lua | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/moonscript/transform.lua b/moonscript/transform.lua index 4db4bb2..805b2b7 100644 --- a/moonscript/transform.lua +++ b/moonscript/transform.lua @@ -1143,7 +1143,7 @@ Value = Transformer({ return { "string", delim, - part + part or "" } else return build.chain({ diff --git a/moonscript/transform.moon b/moonscript/transform.moon index 5c2826c..522b647 100644 --- a/moonscript/transform.moon +++ b/moonscript/transform.moon @@ -598,7 +598,7 @@ Value = Transformer { convert_part = (part) -> if type(part) == "string" or part == nil - {"string", delim, part} + {"string", delim, part or ""} else build.chain { base: "tostring", {"call", {part[2]}} } diff --git a/tests/inputs/string.moon b/tests/inputs/string.moon index 8555205..897056a 100644 --- a/tests/inputs/string.moon +++ b/tests/inputs/string.moon @@ -26,6 +26,7 @@ hola = [===[ mm = [[well trhere]] +oo = "" x = "\\" x = "a\\b" diff --git a/tests/outputs/string.lua b/tests/outputs/string.lua index 0ce2b41..0d1f8d7 100644 --- a/tests/outputs/string.lua +++ b/tests/outputs/string.lua @@ -12,6 +12,7 @@ local hi_there = [[ hi there local well = [==[ "helo" ]==] local hola = [===[ eat noots]===] local mm = [[well trhere]] +local oo = "" local x = "\\" x = "a\\b" x = "\\\n"