diff options
author | Juan M Gómez <info@jmgomez.me> | 2023-09-19 20:16:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 21:16:55 +0200 |
commit | 5568ba0d9f39469891b5e4625ad39ebcfa5e1ee3 (patch) | |
tree | 90e41daaef43f674f847c9fd422f9ab44d57dea1 /tests | |
parent | 81756d1810c7c00e0bb706bb79f5437120ae4c0e (diff) | |
download | Nim-5568ba0d9f39469891b5e4625ad39ebcfa5e1ee3.tar.gz |
`constructor` now uses `result` instead of `this` (#22724)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpp/tconstructor.nim | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/cpp/tconstructor.nim b/tests/cpp/tconstructor.nim index 32fb5e1a2..8c5d4dca2 100644 --- a/tests/cpp/tconstructor.nim +++ b/tests/cpp/tconstructor.nim @@ -46,7 +46,7 @@ type NimClassNoNarent* = object x: int32 proc makeNimClassNoParent(x:int32): NimClassNoNarent {. constructor.} = - this.x = x + result.x = x discard let nimClassNoParent = makeNimClassNoParent(1) @@ -58,11 +58,11 @@ var nimClassNoParentDef {.used.}: NimClassNoNarent #test has a default construc type NimClass* = object of CppClass proc makeNimClass(x:int32): NimClass {. constructor:"NimClass('1 #1) : CppClass(0, #1) ".} = - this.x = x + result.x = x #optinially define the default constructor so we get rid of the cpp warn and we can declare the obj (note: default constructor of 'tyObject_NimClass__apRyyO8cfRsZtsldq1rjKA' is implicitly deleted because base class 'CppClass' has no default constructor) proc makeCppClass(): NimClass {. constructor: "NimClass() : CppClass(0, 0) ".} = - this.x = 1 + result.x = 1 let nimClass = makeNimClass(1) var nimClassDef {.used.}: NimClass #since we explictly defined the default constructor we can declare the obj @@ -95,7 +95,7 @@ type else: discard proc makeNimClassWithDefault(): NimClassWithDefault {.constructor.} = - discard + result = NimClassWithDefault() proc init = for i in 0 .. 1: |