summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/json.nim20
-rw-r--r--tests/stdlib/mjsonexternproc.nim10
-rw-r--r--tests/stdlib/tjsonexternproc.nim5
3 files changed, 25 insertions, 10 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 097952588..73c4f97f4 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -721,6 +721,16 @@ proc getElems*(n: JsonNode, default: seq[JsonNode] = @[]): seq[JsonNode] =
   if n.isNil or n.kind != JArray: return default
   else: return n.elems
 
+proc add*(father, child: JsonNode) =
+  ## Adds `child` to a JArray node `father`.
+  assert father.kind == JArray
+  father.elems.add(child)
+
+proc add*(obj: JsonNode, key: string, val: JsonNode) =
+  ## Sets a field from a `JObject`.
+  assert obj.kind == JObject
+  obj.fields[key] = val
+
 proc `%`*(s: string): JsonNode =
   ## Generic constructor for JSON data. Creates a new `JString JsonNode`.
   new(result)
@@ -909,16 +919,6 @@ proc contains*(node: JsonNode, val: JsonNode): bool =
 proc existsKey*(node: JsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
   ## Deprecated for `hasKey`
 
-proc add*(father, child: JsonNode) =
-  ## Adds `child` to a JArray node `father`.
-  assert father.kind == JArray
-  father.elems.add(child)
-
-proc add*(obj: JsonNode, key: string, val: JsonNode) =
-  ## Sets a field from a `JObject`.
-  assert obj.kind == JObject
-  obj.fields[key] = val
-
 proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
   ## Sets a field from a `JObject`.
   assert(obj.kind == JObject)
diff --git a/tests/stdlib/mjsonexternproc.nim b/tests/stdlib/mjsonexternproc.nim
new file mode 100644
index 000000000..2967a1168
--- /dev/null
+++ b/tests/stdlib/mjsonexternproc.nim
@@ -0,0 +1,10 @@
+# Test case for https://github.com/nim-lang/Nim/issues/6385
+
+import json
+# export json
+
+proc foo*[T](a: T) =
+  let params = %*{
+    "data": [ 1 ]
+  }
+  echo $params
\ No newline at end of file
diff --git a/tests/stdlib/tjsonexternproc.nim b/tests/stdlib/tjsonexternproc.nim
new file mode 100644
index 000000000..ec90e580d
--- /dev/null
+++ b/tests/stdlib/tjsonexternproc.nim
@@ -0,0 +1,5 @@
+# Test case for https://github.com/nim-lang/Nim/issues/6385
+
+import mjsonexternproc
+# import json
+foo(1)
\ No newline at end of file