Automatic deref for everything but pointers in asm/emit (#8891)
Fixes #7249
This commit is contained in:
parent
c033ff990a
commit
af1e84f54d
5 changed files with 42 additions and 10 deletions
21
tests/js/t7249.nim
Normal file
21
tests/js/t7249.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
discard """
|
||||
output: '''
|
||||
a -> 2
|
||||
a <- 2
|
||||
'''
|
||||
"""
|
||||
|
||||
import jsffi
|
||||
|
||||
var a = JsAssoc[cstring, int]{a: 2}
|
||||
|
||||
for z, b in a:
|
||||
echo z, " -> ", b
|
||||
|
||||
proc f =
|
||||
var a = JsAssoc[cstring, int]{a: 2}
|
||||
|
||||
for z, b in a:
|
||||
echo z, " <- ", b
|
||||
|
||||
f()
|
||||
|
|
@ -27,10 +27,10 @@ block:
|
|||
var global = T(a: 11, b: "foo")
|
||||
proc test(): bool =
|
||||
var obj = T(a: 11, b: "foo")
|
||||
{. emit: [result, " = (", obj.addr[], "[0].a == 11);"] .}
|
||||
{. emit: [result, " = ", result, " && (", obj.addr[], "[0].b == \"foo\");"] .}
|
||||
{. emit: [result, " = ", result, " && (", global, "[0].a == 11);"] .}
|
||||
{. emit: [result, " = ", result, " && (", global, "[0].b == \"foo\");"] .}
|
||||
{. emit: [result, " = (", obj.addr[], ".a == 11);"] .}
|
||||
{. emit: [result, " = ", result, " && (", obj.addr[], ".b == \"foo\");"] .}
|
||||
{. emit: [result, " = ", result, " && (", global, ".a == 11);"] .}
|
||||
{. emit: [result, " = ", result, " && (", global, ".b == \"foo\");"] .}
|
||||
echo test()
|
||||
|
||||
# Test addr of field:
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ block: # Test compile-time binary data generation, invalid unicode
|
|||
block: # Test unicode strings
|
||||
const constStr = "Привет!"
|
||||
var jsStr : cstring
|
||||
{.emit: """`jsStr`[0] = "Привет!";""".}
|
||||
{.emit: """`jsStr` = "Привет!";""".}
|
||||
|
||||
doAssert($jsStr == constStr)
|
||||
var runtimeStr = "При"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue