Merge pull request #1709 from juxiliary/devel
Fixing extraneous semicolon in jsgen output
This commit is contained in:
commit
5ee7458883
2 changed files with 35 additions and 1 deletions
|
|
@ -1431,7 +1431,7 @@ proc genObjConstr(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
r.res = toRope("{")
|
r.res = toRope("{")
|
||||||
r.kind = resExpr
|
r.kind = resExpr
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i > 0: app(r.res, ", ")
|
if i > 1: app(r.res, ", ")
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
internalAssert it.kind == nkExprColonExpr
|
internalAssert it.kind == nkExprColonExpr
|
||||||
gen(p, it.sons[1], a)
|
gen(p, it.sons[1], a)
|
||||||
|
|
|
||||||
34
tests/js/testobjs.nim
Normal file
34
tests/js/testobjs.nim
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
## Tests javascript object generation
|
||||||
|
|
||||||
|
type
|
||||||
|
Kg = distinct float
|
||||||
|
Price = int
|
||||||
|
Item = object of RootObj
|
||||||
|
weight: Kg
|
||||||
|
price: Price
|
||||||
|
desc: cstring
|
||||||
|
Person = object of RootObj
|
||||||
|
name: cstring
|
||||||
|
age: int
|
||||||
|
item: Item
|
||||||
|
Test = object
|
||||||
|
name: cstring
|
||||||
|
Recurse[T] = object
|
||||||
|
data: T
|
||||||
|
next: ref Recurse[T]
|
||||||
|
|
||||||
|
var
|
||||||
|
test = Test(name: "Jorden")
|
||||||
|
sword = Item(desc: "pointy", weight: Kg(10.0),
|
||||||
|
price: Price(50))
|
||||||
|
knight = Person(name: "robert", age: 19, item: sword)
|
||||||
|
recurse4 = (ref Recurse[int])(data: 4, next: nil)
|
||||||
|
recurse3 = (ref Recurse[int])(data: 3, next: recurse4)
|
||||||
|
recurse2 = (ref Recurse[int])(data: 2, next: recurse3)
|
||||||
|
recurse1 = Recurse[int](data: 1, next: recurse2)
|
||||||
|
|
||||||
|
|
||||||
|
assert(test.name == "Jorden")
|
||||||
|
assert(knight.age == 19)
|
||||||
|
assert(knight.item.price == 50)
|
||||||
|
assert(recurse1.next.next.data == 3)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue