From e5dbdc1d371101c951dfc8f7671ae795cff652aa Mon Sep 17 00:00:00 2001 From: haxscramper Date: Sun, 9 Aug 2020 15:12:53 +0300 Subject: [PATCH] [FIX] strtabs interpolation in nimscript (#15172) * [FIX] strtabs interpolation in nimscript * [TEST] Use `static` in strtabs test --- lib/pure/strtabs.nim | 2 +- tests/stdlib/tstrtabs.nims | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/stdlib/tstrtabs.nims diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim index 76f90938c3..676e8eb1dc 100644 --- a/lib/pure/strtabs.nim +++ b/lib/pure/strtabs.nim @@ -302,7 +302,7 @@ proc getValue(t: StringTableRef, flags: set[FormatFlag], key: string): string = when defined(js) or defined(nimscript): result = "" else: - if useEnvironment in flags: result = os.getEnv(key).string + if useEnvironment in flags: result = getEnv(key).string else: result = "" if result.len == 0: if useKey in flags: result = '$' & key diff --git a/tests/stdlib/tstrtabs.nims b/tests/stdlib/tstrtabs.nims new file mode 100644 index 0000000000..c8ed4ac406 --- /dev/null +++ b/tests/stdlib/tstrtabs.nims @@ -0,0 +1,5 @@ +import strtabs + +static: + let t = {"name": "John", "city": "Monaco"}.newStringTable + doAssert "${name} lives in ${city}" % t == "John lives in Monaco"