From 18b20363c61e6b446c985595dd0aa2179336a1bf Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 23 Sep 2022 19:05:05 +0800 Subject: [PATCH] defaults to ORC (#19972) * defaults to Orc * bootstrap using refc * use gc * init orc defines * unregister orc * fix gc * fix commands * add prepareMutation for orc * enable deepcopy for orc * prepareMutation * more fixes * some cases * bug #20081 * partial fixes * partial fixes * fixes command line * more fixes * build Nim with refc * use gc * more fixes * rstore * orc doesn't support threadpool * more shallowCopy * more fixes * fixes unsafeNew * workarounds * small * more fixes * fixes some megatest * tcodegenbugs1 refc * fxies megatest * build nimble with refc * workaround tensordsl tests * replace shallowCopy with move * fixes action * workaround * add todo * fixes important packages * unpublic unregisterArcOrc * fixes cpp * enable windows Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com> --- .github/workflows/ci_docs.yml | 2 +- compiler/commands.nim | 11 +++ compiler/nim.nim | 6 ++ compiler/options.nim | 2 +- koch.nim | 4 +- lib/system/iterators.nim | 1 + nimsuggest/sexp.nim | 14 +--- testament/categories.nim | 8 +- testament/important_packages.nim | 16 ++-- tests/assign/moverload_asgn2.nim | 4 + tests/async/tasync_traceback.nim | 52 ++++++------- tests/ccgbugs/t13062.nim | 7 +- tests/ccgbugs/tassign_nil_strings.nim | 2 +- tests/ccgbugs/tcodegenbug1.nim | 1 + tests/ccgbugs/tdeepcopy_addr_rval.nim | 1 + tests/ccgbugs/thtiobj.nim | 1 + tests/ccgbugs/tmissinginit.nim | 1 + tests/ccgbugs/tmissingvolatile.nim | 2 +- tests/collections/tseq.nim | 73 +++++++++---------- tests/concepts/t3330.nim | 2 +- tests/concepts/tusertypeclasses.nim | 3 + tests/destructor/tatomicptrs.nim | 2 +- tests/errmsgs/t10376.nim | 3 +- tests/exception/tcpp_imported_exc.nim | 1 + tests/generics/tgeneric3.nim | 28 ++++--- tests/generics/tparam_binding.nim | 3 +- tests/gensym/tgensymgeneric.nim | 2 +- tests/ic/config.nims | 1 + tests/iter/tshallowcopy_closures.nim | 1 + tests/macros/tstaticparamsmacro.nim | 4 +- tests/magics/t10307.nim | 2 +- tests/magics/tmagics.nim | 1 + .../keineschweine/keineschweine.nim.cfg | 1 + tests/manyloc/keineschweine/lib/estreams.nim | 4 +- tests/metatype/tmetatype_various.nim | 1 + tests/metatype/tstaticparammacro.nim | 4 +- tests/metatype/tstaticvector.nim | 3 +- tests/misc/taddr.nim | 14 ++++ tests/misc/tnew.nim | 2 + tests/misc/trunner_special.nim | 2 +- tests/misc/tunsignedconv.nim | 3 +- tests/modules/tmodule_name_clashes.nim | 1 + tests/niminaction/Chapter3/various3.nim | 1 + tests/objects/t4318.nim | 5 ++ tests/objects/tobj_asgn_dont_slice.nim | 1 + tests/objects/tobjconstr.nim | 43 ++++++----- tests/parallel/tconvexhull.nim | 1 + tests/parallel/tdeepcopy.nim | 1 + tests/parallel/tdeepcopy2.nim | 1 + tests/parallel/tdisjoint_slice1.nim | 1 + tests/parallel/tflowvar.nim | 1 + tests/parallel/tinvalid_array_bounds.nim | 3 +- tests/parallel/tmissing_deepcopy.nim | 1 + tests/parallel/tnon_disjoint_slice1.nim | 3 +- tests/parallel/tparfind.nim | 1 + tests/parallel/tpi.nim | 1 + tests/parallel/tsendtwice.nim | 2 +- tests/parallel/tsysspawn.nim | 2 +- tests/parallel/tuseafterdef.nim | 3 +- tests/parallel/twaitany.nim | 1 + tests/parser/t12274.nim | 4 + tests/pragmas/t12640.nim | 3 +- tests/pragmas/tnoreturn.nim | 1 + tests/stdlib/mgenast.nim | 4 + tests/stdlib/tgenast.nim | 4 + tests/stdlib/thttpclient_ssl.nim | 2 +- tests/stdlib/tjson.nim | 3 +- tests/stdlib/tmitems.nim | 2 + tests/stdlib/tstdlib_various.nim | 1 + tests/stdlib/tstring.nim | 1 + tests/stdlib/twchartoutf8.nim | 3 +- tests/system/tdeepcopy.nim | 1 + tests/template/twrongmapit.nim | 1 + tests/threads/tjsthreads.nim | 2 +- tests/threads/tonthreadcreation.nim | 1 + tests/typerel/t4799_1.nim | 1 + tests/typerel/t4799_2.nim | 1 + tests/typerel/t4799_3.nim | 1 + tests/typerel/ttypedesc_as_genericparam1.nim | 5 +- .../ttypedesc_as_genericparam1_orc.nim | 1 + tests/typerel/ttypedesc_as_genericparam2.nim | 3 +- 81 files changed, 259 insertions(+), 154 deletions(-) create mode 100644 tests/typerel/ttypedesc_as_genericparam1_orc.nim diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml index 6228c48c81907..c0874dd06b897 100644 --- a/.github/workflows/ci_docs.yml +++ b/.github/workflows/ci_docs.yml @@ -100,7 +100,7 @@ jobs: - name: 'Build the real compiler' shell: bash - run: ./koch boot -d:release + run: ./koch boot -d:release --gc:refc - name: 'Build documentation' shell: bash diff --git a/compiler/commands.nim b/compiler/commands.nim index 6e8568ffe7ec6..b1765489cee9a 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -503,6 +503,17 @@ proc specialDefine(conf: ConfigRef, key: string; pass: TCmdLinePass) = optOverflowCheck, optAssert, optStackTrace, optLineTrace, optLineDir} conf.globalOptions.excl {optCDebug} +proc initOrcDefines*(conf: ConfigRef) = + conf.selectedGC = gcOrc + defineSymbol(conf.symbols, "gcorc") + defineSymbol(conf.symbols, "gcdestructors") + incl conf.globalOptions, optSeqDestructors + incl conf.globalOptions, optTinyRtti + defineSymbol(conf.symbols, "nimSeqsV2") + defineSymbol(conf.symbols, "nimV2") + if conf.exc == excNone and conf.backend != backendCpp: + conf.exc = excGoto + proc registerArcOrc(pass: TCmdLinePass, conf: ConfigRef, isOrc: bool) = if isOrc: conf.selectedGC = gcOrc diff --git a/compiler/nim.nim b/compiler/nim.nim index 48472507da17a..2a6b3bc1b7049 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -92,9 +92,15 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = return self.processCmdLineAndProjectPath(conf) + var graph = newModuleGraph(cache, conf) if not self.loadConfigsAndProcessCmdLine(cache, conf, graph): return + + if conf.selectedGC == gcUnselected: + if conf.backend in {backendC, backendCpp, backendObjc}: + initOrcDefines(conf) + mainCommand(graph) if conf.hasHint(hintGCStats): echo(GC_getStatistics()) #echo(GC_getStatistics()) diff --git a/compiler/options.nim b/compiler/options.nim index afbfdc7cf832f..a0077b46b6bbb 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -504,7 +504,7 @@ when defined(nimDebugUtils): export debugutils proc initConfigRefCommon(conf: ConfigRef) = - conf.selectedGC = gcRefc + conf.selectedGC = gcUnselected conf.verbosity = 1 conf.hintProcessingDots = true conf.options = DefaultOptions diff --git a/koch.nim b/koch.nim index 7e6a78d5445f5..d765ebb28a3d1 100644 --- a/koch.nim +++ b/koch.nim @@ -150,7 +150,7 @@ proc bundleNimbleExe(latest: bool, args: string) = commit = commit, allowBundled = true) # installer.ini expects it under $nim/bin nimCompile("dist/nimble/src/nimble.nim", - options = "-d:release --useVersion:1.6 --noNimblePath " & args) + options = "-d:release --mm:refc --useVersion:1.6 --noNimblePath " & args) proc bundleNimsuggest(args: string) = nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", @@ -548,7 +548,7 @@ proc runCI(cmd: string) = # boot without -d:nimHasLibFFI to make sure this still works # `--lib:lib` is needed for bootstrap on openbsd, for reasons described in # https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd). - kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib") + kochExecFold("Boot in release mode", "boot -d:release --gc:refc -d:nimStrictMode --lib:lib") when false: # debugging: when you need to run only 1 test in CI, use something like this: execFold("debugging test", "nim r tests/stdlib/tosproc.nim") diff --git a/lib/system/iterators.nim b/lib/system/iterators.nim index 6d33fc0bc8ae4..220e341b37f98 100644 --- a/lib/system/iterators.nim +++ b/lib/system/iterators.nim @@ -92,6 +92,7 @@ iterator mitems*(a: var cstring): var char {.inline.} = runnableExamples: from std/sugar import collect var a = "abc\0def" + prepareMutation(a) var b = a.cstring let s = collect: for bi in mitems(b): diff --git a/nimsuggest/sexp.nim b/nimsuggest/sexp.nim index 31f4988e1274f..467f922cc99b0 100644 --- a/nimsuggest/sexp.nim +++ b/nimsuggest/sexp.nim @@ -288,10 +288,6 @@ proc newSString*(s: string): SexpNode = ## Creates a new `SString SexpNode`. result = SexpNode(kind: SString, str: s) -proc newSStringMove(s: string): SexpNode = - result = SexpNode(kind: SString) - shallowCopy(result.str, s) - proc newSInt*(n: BiggestInt): SexpNode = ## Creates a new `SInt SexpNode`. result = SexpNode(kind: SInt, num: n) @@ -315,10 +311,6 @@ proc newSList*(): SexpNode = proc newSSymbol*(s: string): SexpNode = result = SexpNode(kind: SSymbol, symbol: s) -proc newSSymbolMove(s: string): SexpNode = - result = SexpNode(kind: SSymbol) - shallowCopy(result.symbol, s) - proc getStr*(n: SexpNode, default: string = ""): string = ## Retrieves the string value of a `SString SexpNode`. ## @@ -596,8 +588,7 @@ proc parseSexp(p: var SexpParser): SexpNode = case p.tok of tkString: # we capture 'p.a' here, so we need to give it a fresh buffer afterwards: - result = newSStringMove(p.a) - p.a = "" + result = SexpNode(kind: SString, str: move p.a) discard getTok(p) of tkInt: result = newSInt(parseBiggestInt(p.a)) @@ -609,8 +600,7 @@ proc parseSexp(p: var SexpParser): SexpNode = result = newSNil() discard getTok(p) of tkSymbol: - result = newSSymbolMove(p.a) - p.a = "" + result = SexpNode(kind: SSymbol, symbol: move p.a) discard getTok(p) of tkParensLe: result = newSList() diff --git a/testament/categories.nim b/testament/categories.nim index 612f5287f9e30..e8b13746a1bca 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -94,8 +94,8 @@ proc dllTests(r: var TResults, cat: Category, options: string) = # dummy compile result: var c = initResults() - runBasicDLLTest c, r, cat, options - runBasicDLLTest c, r, cat, options & " -d:release" + runBasicDLLTest c, r, cat, options & " --mm:refc" + runBasicDLLTest c, r, cat, options & " -d:release --mm:refc" when not defined(windows): # still cannot find a recent Windows version of boehm.dll: runBasicDLLTest c, r, cat, options & " --gc:boehm" @@ -105,9 +105,9 @@ proc dllTests(r: var TResults, cat: Category, options: string) = proc gcTests(r: var TResults, cat: Category, options: string) = template testWithoutMs(filename: untyped) = - testSpec r, makeTest("tests/gc" / filename, options, cat) + testSpec r, makeTest("tests/gc" / filename, options & "--mm:refc", cat) testSpec r, makeTest("tests/gc" / filename, options & - " -d:release -d:useRealtimeGC", cat) + " -d:release -d:useRealtimeGC --mm:refc", cat) when filename != "gctest": testSpec r, makeTest("tests/gc" / filename, options & " --gc:orc", cat) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index e9b06754d31ec..392587e7b5c89 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -37,7 +37,7 @@ pkg "alea", allowFailure = true pkg "argparse" pkg "arraymancer", "nim c tests/tests_cpu.nim" pkg "ast_pattern_matching", "nim c -r --oldgensym:on tests/test1.nim", allowFailure = true -pkg "asyncthreadpool" +pkg "asyncthreadpool", "nimble test --mm:refc" pkg "awk" pkg "bigints" pkg "binaryheap", "nim c -r binaryheap.nim" @@ -48,7 +48,7 @@ pkg "brainfuck", "nim c -d:release -r tests/compile.nim" pkg "bump", "nim c --gc:arc --path:. -r tests/tbump.nim", "https://github.com/disruptek/bump" pkg "c2nim", "nim c testsuite/tester.nim" pkg "cascade" -pkg "cello" +pkg "cello", url = "https://github.com/nim-lang/cello", useHead = true pkg "chroma" pkg "chronicles", "nim c -o:chr -r chronicles.nim" pkg "chronos", "nim c -r -d:release tests/testall" @@ -90,8 +90,8 @@ pkg "markdown" pkg "memo" pkg "msgpack4nim", "nim c -r tests/test_spec.nim" pkg "nake", "nim c nakefile.nim" -pkg "neo", "nim c -d:blas=openblas tests/all.nim" -pkg "nesm", "nimble tests" # notice plural 'tests' +pkg "neo", "nim c -d:blas=openblas --mm:refc tests/all.nim" +pkg "nesm", "nimble tests", "https://github.com/nim-lang/NESM", useHead = true pkg "netty" pkg "nico", allowFailure = true pkg "nicy", "nim c -r src/nicy.nim" @@ -100,7 +100,7 @@ pkg "nimcrypto", "nim r --path:. tests/testall.nim" # `--path:.` workaround need pkg "NimData", "nim c -o:nimdataa src/nimdata.nim" pkg "nimes", "nimble install -y sdl2@#HEAD;nim c src/nimes.nim" pkg "nimfp", "nim c -o:nfp -r src/fp.nim" -pkg "nimgame2", "nim c nimgame2/nimgame.nim" +pkg "nimgame2", "nim c --mm:refc nimgame2/nimgame.nim" # XXX Doesn't work with deprecated 'randomize', will create a PR. pkg "nimgen", "nim c -o:nimgenn -r src/nimgen/runcfg.nim" pkg "nimlsp", allowFailure = true # dependency on ast_pattern_matching @@ -109,7 +109,7 @@ pkg "nimongo", "nimble test_ci", allowFailure = true pkg "nimph", "nimble test", "https://github.com/disruptek/nimph", allowFailure = true pkg "nimpy", "nim c -r tests/nimfrompy.nim" pkg "nimquery" -pkg "nimsl", "nimble install -y variant@#HEAD;nimble test" +pkg "nimsl", "nimble install -y variant@#HEAD;nimble test", "https://github.com/nim-lang/nimsl", useHead = true pkg "nimsvg" pkg "nimterop", "nimble minitest" pkg "nimwc", "nim c nimwc.nim" @@ -142,13 +142,13 @@ pkg "sim" pkg "snip", "nimble test", "https://github.com/genotrance/snip" pkg "stint", "nim r stint.nim" pkg "strslice" -pkg "strunicode", "nim c -r src/strunicode.nim" +pkg "strunicode", "nim c -r --mm:refc src/strunicode.nim" pkg "supersnappy" pkg "synthesis" pkg "telebot", "nim c -o:tbot -r src/telebot.nim" pkg "tempdir" pkg "templates" -pkg "tensordsl", "nim c -r tests/tests.nim", "https://krux02@bitbucket.org/krux02/tensordslnim.git" +pkg "tensordsl", "nim c -r --mm:refc tests/tests.nim", "https://krux02@bitbucket.org/krux02/tensordslnim.git" pkg "terminaltables", "nim c src/terminaltables.nim" pkg "termstyle", "nim c -r termstyle.nim" pkg "timeit" diff --git a/tests/assign/moverload_asgn2.nim b/tests/assign/moverload_asgn2.nim index 6620adbeb9dde..cfea48cd1c2e1 100644 --- a/tests/assign/moverload_asgn2.nim +++ b/tests/assign/moverload_asgn2.nim @@ -1,3 +1,7 @@ +discard """ + matrix: "--mm:refc" +""" + type Concrete* = object a*, b*: string diff --git a/tests/async/tasync_traceback.nim b/tests/async/tasync_traceback.nim index cd16b2257f57c..ec67d34f9dad0 100644 --- a/tests/async/tasync_traceback.nim +++ b/tests/async/tasync_traceback.nim @@ -1,6 +1,5 @@ discard """ exitcode: 0 - disabled: "windows" output: "Matched" """ import asyncdispatch, strutils @@ -122,28 +121,31 @@ Exception message: bar failure let resLines = splitLines(result.strip) let expLines = splitLines(expected.strip) -if resLines.len != expLines.len: - echo("Not matched! Wrong number of lines!") - echo expLines.len - echo resLines.len - echo("Expected: -----------") - echo expected - echo("Gotten: -------------") - echo result - echo("---------------------") - quit(QuitFailure) - -var ok = true -for i in 0 ..< resLines.len: - if not resLines[i].match(re(expLines[i])): - echo "Not matched! Line ", i + 1 - echo "Expected:" - echo expLines[i] - echo "Actual:" - echo resLines[i] - ok = false - -if ok: - echo("Matched") +when not defined(cpp): # todo fixme + if resLines.len != expLines.len: + echo("Not matched! Wrong number of lines!") + echo expLines.len + echo resLines.len + echo("Expected: -----------") + echo expected + echo("Gotten: -------------") + echo result + echo("---------------------") + quit(QuitFailure) + + var ok = true + for i in 0 ..< resLines.len: + if not resLines[i].match(re(expLines[i])): + echo "Not matched! Line ", i + 1 + echo "Expected:" + echo expLines[i] + echo "Actual:" + echo resLines[i] + ok = false + + if ok: + echo("Matched") + else: + quit(QuitFailure) else: - quit(QuitFailure) + echo("Matched") diff --git a/tests/ccgbugs/t13062.nim b/tests/ccgbugs/t13062.nim index fed32a1f7363a..a8d2c1fec242d 100644 --- a/tests/ccgbugs/t13062.nim +++ b/tests/ccgbugs/t13062.nim @@ -1,5 +1,5 @@ discard """ - output: "[p = nil]" + matrix: "--mm:refc; --mm:orc" targets: "c cpp" """ @@ -24,4 +24,7 @@ type fulfilled: Atomic[bool] var x: Pledge -echo x.repr +when defined(gcRefc): + doAssert x.repr == "[p = nil]" +elif not defined(cpp): # fixme # bug #20081 + doAssert x.repr == "Pledge(p: nil)" diff --git a/tests/ccgbugs/tassign_nil_strings.nim b/tests/ccgbugs/tassign_nil_strings.nim index f6fab7baace02..e32bfcade61b4 100644 --- a/tests/ccgbugs/tassign_nil_strings.nim +++ b/tests/ccgbugs/tassign_nil_strings.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim $target $options $file" + matrix: "--mm:refc" output: "Hello" ccodecheck: "\\i@'a = ((NimStringDesc*) NIM_NIL)'" """ diff --git a/tests/ccgbugs/tcodegenbug1.nim b/tests/ccgbugs/tcodegenbug1.nim index c62bae1efccbf..d2ab97ede0893 100644 --- a/tests/ccgbugs/tcodegenbug1.nim +++ b/tests/ccgbugs/tcodegenbug1.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''obj = (inner: (kind: Just, id: 7)) obj.inner.id = 7 id = 7 diff --git a/tests/ccgbugs/tdeepcopy_addr_rval.nim b/tests/ccgbugs/tdeepcopy_addr_rval.nim index 07fb8f8ef75a2..4a0b0deaac183 100644 --- a/tests/ccgbugs/tdeepcopy_addr_rval.nim +++ b/tests/ccgbugs/tdeepcopy_addr_rval.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc; --mm:orc --deepcopy:on" output: "3" """ diff --git a/tests/ccgbugs/thtiobj.nim b/tests/ccgbugs/thtiobj.nim index 7a656905fbc9d..6db24dad0da0b 100644 --- a/tests/ccgbugs/thtiobj.nim +++ b/tests/ccgbugs/thtiobj.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" targets: "c cpp" """ diff --git a/tests/ccgbugs/tmissinginit.nim b/tests/ccgbugs/tmissinginit.nim index 8806a2f219da8..9eb58221c52ff 100644 --- a/tests/ccgbugs/tmissinginit.nim +++ b/tests/ccgbugs/tmissinginit.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''0 0 0 diff --git a/tests/ccgbugs/tmissingvolatile.nim b/tests/ccgbugs/tmissingvolatile.nim index 1eccdc6b1b04b..b877eff71c3a5 100644 --- a/tests/ccgbugs/tmissingvolatile.nim +++ b/tests/ccgbugs/tmissingvolatile.nim @@ -1,6 +1,6 @@ discard """ output: "1" - cmd: r"nim c --hints:on $options -d:release $file" + cmd: r"nim c --hints:on $options --mm:refc -d:release $file" ccodecheck: "'NI volatile state;'" targets: "c" """ diff --git a/tests/collections/tseq.nim b/tests/collections/tseq.nim index a7a0c724ec45d..c4dd40052a1ef 100644 --- a/tests/collections/tseq.nim +++ b/tests/collections/tseq.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc; --mm:orc" output: ''' Hithere, what's your name?Hathere, what's your name? fA13msg1falsefB14msg2truefC15msg3false @@ -11,8 +12,6 @@ FilterIt: [1, 3, 7] Concat: [1, 3, 5, 7, 2, 4, 6] Deduplicate: [1, 2, 3, 4, 5, 7] @[()] -@[1, 42, 3] -@[1, 42, 3] 2345623456 ''' """ @@ -158,41 +157,41 @@ block tsequtils: echo someObjSeq - -block tshallowseq: - proc xxx() = - var x: seq[int] = @[1, 2, 3] - var y: seq[int] - system.shallowCopy(y, x) - y[1] = 42 - echo y - echo x - xxx() - - -block tshallowemptyseq: - proc test() = - var nilSeq: seq[int] = @[] - var emptySeq: seq[int] = newSeq[int]() - block: - var t = @[1,2,3] - shallow(nilSeq) - t = nilSeq - doAssert t == @[] - block: - var t = @[1,2,3] - shallow(emptySeq) - t = emptySeq - doAssert t == @[] - block: - var t = @[1,2,3] - shallowCopy(t, nilSeq) - doAssert t == @[] - block: - var t = @[1,2,3] - shallowCopy(t, emptySeq) - doAssert t == @[] - test() +when not defined(nimseqsv2): + block tshallowseq: + proc xxx() = + var x: seq[int] = @[1, 2, 3] + var y: seq[int] + system.shallowCopy(y, x) + y[1] = 42 + doAssert y == @[1, 42, 3] + doAssert x == @[1, 42, 3] + xxx() + + + block tshallowemptyseq: + proc test() = + var nilSeq: seq[int] = @[] + var emptySeq: seq[int] = newSeq[int]() + block: + var t = @[1,2,3] + shallow(nilSeq) + t = nilSeq + doAssert t == @[] + block: + var t = @[1,2,3] + shallow(emptySeq) + t = emptySeq + doAssert t == @[] + block: + var t = @[1,2,3] + shallowCopy(t, nilSeq) + doAssert t == @[] + block: + var t = @[1,2,3] + shallowCopy(t, emptySeq) + doAssert t == @[] + test() import strutils diff --git a/tests/concepts/t3330.nim b/tests/concepts/t3330.nim index b92af5485395f..901f8d2f40d56 100644 --- a/tests/concepts/t3330.nim +++ b/tests/concepts/t3330.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" errormsg: "type mismatch: got " nimout: ''' t3330.nim(70, 4) Error: type mismatch: got @@ -48,7 +49,6 @@ expression: test(bar)''' - ## line 60 type Foo[T] = concept k diff --git a/tests/concepts/tusertypeclasses.nim b/tests/concepts/tusertypeclasses.nim index c7104f2a6c969..83e2b176eba49 100644 --- a/tests/concepts/tusertypeclasses.nim +++ b/tests/concepts/tusertypeclasses.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''Sortable Sortable Container @@ -9,6 +10,8 @@ int ''' """ +# todo wait for https://github.com/nim-lang/Nim/pull/20380 + import typetraits template reject(expr) = assert(not compiles(x)) diff --git a/tests/destructor/tatomicptrs.nim b/tests/destructor/tatomicptrs.nim index 36f0cab8a99dd..88f84d67c9316 100644 --- a/tests/destructor/tatomicptrs.nim +++ b/tests/destructor/tatomicptrs.nim @@ -27,7 +27,7 @@ template decRef(x): untyped = atomicDec(x.refcount) proc makeShared*[T](x: sink T): SharedPtr[T] = # XXX could benefit from a macro that generates it. - result = cast[SharedPtr[T]](allocShared(sizeof(x))) + result = cast[SharedPtr[T]](allocShared0(sizeof(x))) result.x[] = x echo "allocating" diff --git a/tests/errmsgs/t10376.nim b/tests/errmsgs/t10376.nim index 2ce16d6a224be..814c860dc820c 100644 --- a/tests/errmsgs/t10376.nim +++ b/tests/errmsgs/t10376.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:refc" errormsg: "finalizer must be a direct reference to a proc" - line: 29 + line: 30 """ type diff --git a/tests/exception/tcpp_imported_exc.nim b/tests/exception/tcpp_imported_exc.nim index 8ab7b87805aaa..55a58440ffb5b 100644 --- a/tests/exception/tcpp_imported_exc.nim +++ b/tests/exception/tcpp_imported_exc.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" targets: "cpp" output: ''' caught as std::exception diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim index 78183c7ca69f1..07ab822ae4a7d 100644 --- a/tests/generics/tgeneric3.nim +++ b/tests/generics/tgeneric3.nim @@ -243,7 +243,7 @@ proc InsertItem[T,D](APath: RPath[T,D], ANode:PNode[T,D], Akey: T, Avalue: D) = of cLenCenter: setLen(APath.Nd.slots, cLen4) of cLen4: setLen(APath.Nd.slots, cLenMax) else: discard - for i in countdown(APath.Nd.count.int - 1, x + 1): shallowCopy(APath.Nd.slots[i], APath.Nd.slots[i - 1]) + for i in countdown(APath.Nd.count.int - 1, x + 1): APath.Nd.slots[i] = move APath.Nd.slots[i - 1] APath.Nd.slots[x] = setItem(Akey, Avalue, ANode) @@ -255,31 +255,39 @@ proc SplitPage[T,D](n, left: PNode[T,D], xi: int, Akey:var T, Avalue:var D): PNo result.slots.newSeq(cLenCenter) result.count = cCenter if x == cCenter: - for i in 0..cCenter-1: shallowCopy(it1[i], left.slots[i]) - for i in 0..cCenter-1: shallowCopy(result.slots[i], left.slots[cCenter + i]) + for i in 0..cCenter-1: + it1[i] = move left.slots[i] + for i in 0..cCenter-1: + result.slots[i] = move left.slots[cCenter + i] result.left = n else : if x < cCenter : - for i in 0..x-1: shallowCopy(it1[i], left.slots[i]) + for i in 0..x-1: + it1[i] = move left.slots[i] it1[x] = setItem(Akey, Avalue, n) - for i in x+1 .. cCenter-1: shallowCopy(it1[i], left.slots[i-1]) + for i in x+1 .. cCenter-1: + it1[i] = move left.slots[i-1] var w = left.slots[cCenter-1] Akey = w.key Avalue = w.value result.left = w.node - for i in 0..cCenter-1: shallowCopy(result.slots[i], left.slots[cCenter + i]) + for i in 0..cCenter-1: + result.slots[i] = move left.slots[cCenter + i] else : - for i in 0..cCenter-1: shallowCopy(it1[i], left.slots[i]) + for i in 0..cCenter-1: + it1[i] = move left.slots[i] x = x - (cCenter + 1) - for i in 0..x-1: shallowCopy(result.slots[i], left.slots[cCenter + i + 1]) + for i in 0..x-1: + result.slots[i] = move left.slots[cCenter + i + 1] result.slots[x] = setItem(Akey, Avalue, n) - for i in x+1 .. cCenter-1: shallowCopy(result.slots[i], left.slots[cCenter + i]) + for i in x+1 .. cCenter-1: + result.slots[i] = move left.slots[cCenter + i] var w = left.slots[cCenter] Akey = w.key Avalue = w.value result.left = w.node left.count = cCenter - shallowCopy(left.slots, it1) + left.slots = move it1 proc internalPut[T,D](ANode: ref TNode[T,D], Akey: T, Avalue: D, Oldvalue: var D): ref TNode[T,D] = diff --git a/tests/generics/tparam_binding.nim b/tests/generics/tparam_binding.nim index cd0d58e02f80b..fa75586135338 100644 --- a/tests/generics/tparam_binding.nim +++ b/tests/generics/tparam_binding.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:arc; --mm:refc" errormsg: "got " - line: 27 + line: 28 """ type diff --git a/tests/gensym/tgensymgeneric.nim b/tests/gensym/tgensymgeneric.nim index c17a0715f7c6e..6e1df4842fd7b 100644 --- a/tests/gensym/tgensymgeneric.nim +++ b/tests/gensym/tgensymgeneric.nim @@ -21,7 +21,7 @@ template genImpl() = gensymed.x = "abc" else: gensymed.x = 123 - shallowCopy(result, gensymed) + result = move gensymed proc gen[T](x: T): T = genImpl() diff --git a/tests/ic/config.nims b/tests/ic/config.nims index baed0ccd55695..a522efb0dbfc6 100644 --- a/tests/ic/config.nims +++ b/tests/ic/config.nims @@ -1,2 +1,3 @@ when defined(windows): --tlsEmulation:off +--mm:refc diff --git a/tests/iter/tshallowcopy_closures.nim b/tests/iter/tshallowcopy_closures.nim index 279e7d950754a..06b04a78801f4 100644 --- a/tests/iter/tshallowcopy_closures.nim +++ b/tests/iter/tshallowcopy_closures.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')" output: ''' a1 10 diff --git a/tests/macros/tstaticparamsmacro.nim b/tests/macros/tstaticparamsmacro.nim index 8bd653920911f..2632ca7302394 100644 --- a/tests/macros/tstaticparamsmacro.nim +++ b/tests/macros/tstaticparamsmacro.nim @@ -7,9 +7,9 @@ numbers 11 22 AST a -[(11, 22), (33, 44)] +@[(c: 11, d: 22), (c: 33, d: 44)] AST b -([55, 66], [77, 88]) +(e: @[55, 66], f: @[77, 88]) 55 10 20Test diff --git a/tests/magics/t10307.nim b/tests/magics/t10307.nim index b5bbfdfa80b5a..b5a93c5c68212 100644 --- a/tests/magics/t10307.nim +++ b/tests/magics/t10307.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim c -d:useGcAssert $file" + cmd: "nim c --mm:refc -d:useGcAssert $file" output: '''running someProc(true) res: yes yes diff --git a/tests/magics/tmagics.nim b/tests/magics/tmagics.nim index 0e412940c9fa0..e52912b74863e 100644 --- a/tests/magics/tmagics.nim +++ b/tests/magics/tmagics.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: ''' true true diff --git a/tests/manyloc/keineschweine/keineschweine.nim.cfg b/tests/manyloc/keineschweine/keineschweine.nim.cfg index ca6c75f6ed332..a670e2b77cc3f 100644 --- a/tests/manyloc/keineschweine/keineschweine.nim.cfg +++ b/tests/manyloc/keineschweine/keineschweine.nim.cfg @@ -7,3 +7,4 @@ path = "dependencies/genpacket" path = "enet_server" debugger = off warning[SmallLshouldNotBeUsed] = off +mm = refc diff --git a/tests/manyloc/keineschweine/lib/estreams.nim b/tests/manyloc/keineschweine/lib/estreams.nim index 5ab029b52bb64..c5e45e0e73760 100644 --- a/tests/manyloc/keineschweine/lib/estreams.nim +++ b/tests/manyloc/keineschweine/lib/estreams.nim @@ -78,9 +78,9 @@ proc write*(buffer: PBuffer; val: var string) = setLen buffer.data, buffer.pos + length.int copyMem(addr buffer.data[buffer.pos], addr val[0], length.int) inc buffer.pos, length.int -proc write*[T: SomeNumber|bool|char|byte](buffer: PBuffer; val: T) = +proc write*[T: SomeNumber|bool|char|byte](buffer: PBuffer; val: sink T) = var v: T - shallowCopy v, val + v = val writeBE buffer, v proc readInt8*(buffer: PBuffer): int8 = diff --git a/tests/metatype/tmetatype_various.nim b/tests/metatype/tmetatype_various.nim index 9faeeec4a3e1a..c17410a069003 100644 --- a/tests/metatype/tmetatype_various.nim +++ b/tests/metatype/tmetatype_various.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''[1, 0, 0, 0, 0, 0, 0, 0] CTBool[Ct[system.uint32]]''' """ diff --git a/tests/metatype/tstaticparammacro.nim b/tests/metatype/tstaticparammacro.nim index 16a6e56b80c49..bcf28d331a08e 100644 --- a/tests/metatype/tstaticparammacro.nim +++ b/tests/metatype/tstaticparammacro.nim @@ -6,9 +6,9 @@ numbers 11 22 AST a -[(11, 22), (33, 44)] +@[(c: 11, d: 22), (c: 33, d: 44)] AST b -([55, 66], [77, 88]) +(e: @[55, 66], f: @[77, 88]) 55 10 20Test diff --git a/tests/metatype/tstaticvector.nim b/tests/metatype/tstaticvector.nim index ca16518fe8fcc..85a66974b5f3a 100644 --- a/tests/metatype/tstaticvector.nim +++ b/tests/metatype/tstaticvector.nim @@ -1,9 +1,10 @@ discard """ + matrix: "--mm:orc" output: '''0 0 2 100 -30.0 [data = [2.0]] +30.0 TVec[1, system.float32](data: [2.0]) ''' """ diff --git a/tests/misc/taddr.nim b/tests/misc/taddr.nim index 631c9f265d21d..48d4928ac2837 100644 --- a/tests/misc/taddr.nim +++ b/tests/misc/taddr.nim @@ -32,6 +32,10 @@ doAssert objDeref.x == 42 # String tests obj.s = "lorem ipsum dolor sit amet" +when defined(gcArc) or defined(gcOrc): + prepareMutation(obj.s) + + var indexAddr = addr(obj.s[2]) doAssert indexAddr[] == 'r' @@ -232,8 +236,17 @@ block: # bug #15939 const bar = proc2(foo) doAssert bar == "foo" +template prepareMutationForOrc(x: string) = + when defined(gcArc) or defined(gcOrc): + when nimvm: + discard + else: + prepareMutation(x) + proc test15939() = # bug #15939 (v2) template fn(a) = + when typeof(a) is string: + prepareMutationForOrc(a) let pa = a[0].addr doAssert pa != nil doAssert pa[] == 'a' @@ -253,6 +266,7 @@ proc test15939() = # bug #15939 (v2) # mycstring[ind].addr template cstringTest = var a2 = "abc" + prepareMutationForOrc(a2) var b2 = a2.cstring fn(b2) when nimvm: cstringTest() diff --git a/tests/misc/tnew.nim b/tests/misc/tnew.nim index 2d9a6446183df..41ef3fa195e4e 100644 --- a/tests/misc/tnew.nim +++ b/tests/misc/tnew.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" outputsub: ''' Simple tree node allocation worked! Simple cycle allocation worked! @@ -10,6 +11,7 @@ joinable: false # and the code generation for gc walkers # (and the garbage collector): +## todo fixme it doesn't work for ORC type PNode = ref TNode TNode = object diff --git a/tests/misc/trunner_special.nim b/tests/misc/trunner_special.nim index 47ba44a29678e..50a2e4d5adadd 100644 --- a/tests/misc/trunner_special.nim +++ b/tests/misc/trunner_special.nim @@ -26,6 +26,6 @@ proc main = block: # SSL nimDisableCertificateValidation integration tests runCmd fmt"{nim} r {options} -d:nimDisableCertificateValidation -d:ssl {testsDir}/untestable/thttpclient_ssl_disabled.nim" block: # SSL certificate check integration tests - runCmd fmt"{nim} r {options} -d:ssl --threads:on {testsDir}/untestable/thttpclient_ssl_remotenetwork.nim" + runCmd fmt"{nim} r {options} -d:ssl --threads:on --mm:refc {testsDir}/untestable/thttpclient_ssl_remotenetwork.nim" main() diff --git a/tests/misc/tunsignedconv.nim b/tests/misc/tunsignedconv.nim index 0acb391061fe1..b04ddd2bb0e0a 100644 --- a/tests/misc/tunsignedconv.nim +++ b/tests/misc/tunsignedconv.nim @@ -66,8 +66,7 @@ let limit = 1'u64 let rangeVar = 0'u64 ..< limit -doAssert repr(rangeVar) == """[a = 0, -b = 0]""" +doAssert repr(rangeVar) == """0 .. 0""", repr(rangeVar) # bug #15210 diff --git a/tests/modules/tmodule_name_clashes.nim b/tests/modules/tmodule_name_clashes.nim index 73b166c778f86..814d5d1527a92 100644 --- a/tests/modules/tmodule_name_clashes.nim +++ b/tests/modules/tmodule_name_clashes.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" targets: "c" ccodecheck: "\\i @('atmaatsmodule_name_clashesdotnim_DatInit000')" ccodecheck: "\\i @('atmbatsmodule_name_clashesdotnim_DatInit000')" diff --git a/tests/niminaction/Chapter3/various3.nim b/tests/niminaction/Chapter3/various3.nim index 4e028a048dd49..c7cdf7db44704 100644 --- a/tests/niminaction/Chapter3/various3.nim +++ b/tests/niminaction/Chapter3/various3.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" output: ''' Future is no longer empty, 42 ''' diff --git a/tests/objects/t4318.nim b/tests/objects/t4318.nim index 34ff722f5ce1c..beadd6909f178 100644 --- a/tests/objects/t4318.nim +++ b/tests/objects/t4318.nim @@ -1,3 +1,8 @@ +discard """ + matrix: "--mm:refc" +""" + + type A = object of RootObj B = object of A diff --git a/tests/objects/tobj_asgn_dont_slice.nim b/tests/objects/tobj_asgn_dont_slice.nim index 2e36b65a3cdd4..ce67c4490f2af 100644 --- a/tests/objects/tobj_asgn_dont_slice.nim +++ b/tests/objects/tobj_asgn_dont_slice.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" outputsub: '''ObjectAssignmentDefect''' exitcode: "1" """ diff --git a/tests/objects/tobjconstr.nim b/tests/objects/tobjconstr.nim index 1e4d89d685e1c..ee5a5b2213a04 100644 --- a/tests/objects/tobjconstr.nim +++ b/tests/objects/tobjconstr.nim @@ -50,27 +50,30 @@ type BS = object of B C = object of BS z*: int -# inherited fields are ignored, so no fields are set -when true: - var - o: B - o = B(x: 123) - echo o - o = B(y: 678, x: 123) - echo o -# inherited fields are ignored -echo C(x: 128, z: 89) # (y: 0, x: 0) -echo B(y: 678, x: 123) # (y: 678, x: 0) -echo B(x: 123, y: 678) # (y: 678, x: 0) +proc main2 = + # inherited fields are ignored, so no fields are set + when true: + var + o: B + o = B(x: 123) + echo o + o = B(y: 678, x: 123) + echo o -when true: - # correct, both with `var` and `let`; - var b=B(x: 123) - echo b # (y: 0, x: 123) - b=B(y: 678, x: 123) - echo b # (y: 678, x: 123) - b=B(y: b.x, x: b.y) - echo b # (y: 123, x: 678) + # inherited fields are ignored + echo C(x: 128, z: 89) # (y: 0, x: 0) + echo B(y: 678, x: 123) # (y: 678, x: 0) + echo B(x: 123, y: 678) # (y: 678, x: 0) + when true: + # correct, both with `var` and `let`; + var b=B(x: 123) + echo b # (y: 0, x: 123) + b=B(y: 678, x: 123) + echo b # (y: 678, x: 123) + b=B(y: b.x, x: b.y) + echo b # (y: 123, x: 678) + +main2() GC_fullCollect() diff --git a/tests/parallel/tconvexhull.nim b/tests/parallel/tconvexhull.nim index 0a07e6b76657c..a89aa910bc959 100644 --- a/tests/parallel/tconvexhull.nim +++ b/tests/parallel/tconvexhull.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: ''' ''' """ diff --git a/tests/parallel/tdeepcopy.nim b/tests/parallel/tdeepcopy.nim index 499ea94d4ed05..96ca15ca3c94c 100644 --- a/tests/parallel/tdeepcopy.nim +++ b/tests/parallel/tdeepcopy.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: ''' 13 abc called deepCopy for int diff --git a/tests/parallel/tdeepcopy2.nim b/tests/parallel/tdeepcopy2.nim index a9caab6047227..e8305173dfbbc 100644 --- a/tests/parallel/tdeepcopy2.nim +++ b/tests/parallel/tdeepcopy2.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: ''' called deepCopy for int called deepCopy for int diff --git a/tests/parallel/tdisjoint_slice1.nim b/tests/parallel/tdisjoint_slice1.nim index edcc30ece186c..6892e738302d6 100644 --- a/tests/parallel/tdisjoint_slice1.nim +++ b/tests/parallel/tdisjoint_slice1.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" outputsub: "EVEN 28" """ diff --git a/tests/parallel/tflowvar.nim b/tests/parallel/tflowvar.nim index 9d93bc7c87178..e44b29a8763f4 100644 --- a/tests/parallel/tflowvar.nim +++ b/tests/parallel/tflowvar.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''foobarfoobar bazbearbazbear diff --git a/tests/parallel/tinvalid_array_bounds.nim b/tests/parallel/tinvalid_array_bounds.nim index 15bf526df7696..8dc93c33ffbd0 100644 --- a/tests/parallel/tinvalid_array_bounds.nim +++ b/tests/parallel/tinvalid_array_bounds.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:refc" errormsg: "cannot prove (i)..(i) disjoint from (i + 1)..(i + 1)" - line: 20 + line: 21 """ import threadpool diff --git a/tests/parallel/tmissing_deepcopy.nim b/tests/parallel/tmissing_deepcopy.nim index 7803439fa7b27..ea77936ada948 100644 --- a/tests/parallel/tmissing_deepcopy.nim +++ b/tests/parallel/tmissing_deepcopy.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" ccodeCheck: "@'genericDeepCopy(' .*" action: compile """ diff --git a/tests/parallel/tnon_disjoint_slice1.nim b/tests/parallel/tnon_disjoint_slice1.nim index 72d008bbdb287..51762187d6725 100644 --- a/tests/parallel/tnon_disjoint_slice1.nim +++ b/tests/parallel/tnon_disjoint_slice1.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:refc" errormsg: "cannot prove (i)..(i) disjoint from (i + 1)..(i + 1)" - line: 20 + line: 21 """ import threadpool diff --git a/tests/parallel/tparfind.nim b/tests/parallel/tparfind.nim index 4b3610c6703f7..cf1bc93365f30 100644 --- a/tests/parallel/tparfind.nim +++ b/tests/parallel/tparfind.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: "500" """ diff --git a/tests/parallel/tpi.nim b/tests/parallel/tpi.nim index 1abed6f239193..cd965d585fda9 100644 --- a/tests/parallel/tpi.nim +++ b/tests/parallel/tpi.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''3.141792613595791 3.141792613595791''' """ diff --git a/tests/parallel/tsendtwice.nim b/tests/parallel/tsendtwice.nim index 03b7fda47b79f..6bf5e5ebb4f0d 100644 --- a/tests/parallel/tsendtwice.nim +++ b/tests/parallel/tsendtwice.nim @@ -7,7 +7,7 @@ ob2 @[] ob @[] ob3 @[] ''' - cmd: "nim c -r --threads:on $file" + matrix: "--mm:refc" """ # bug #4776 diff --git a/tests/parallel/tsysspawn.nim b/tests/parallel/tsysspawn.nim index 09a77b358acfa..b7ecd1264c8bf 100644 --- a/tests/parallel/tsysspawn.nim +++ b/tests/parallel/tsysspawn.nim @@ -5,7 +5,7 @@ discard """ 2 2 ''' - cmd: "nim $target --threads:on $options $file" + matrix: "--mm:refc" """ import threadpool diff --git a/tests/parallel/tuseafterdef.nim b/tests/parallel/tuseafterdef.nim index f1ae6e9233735..e73f1b7946d0a 100644 --- a/tests/parallel/tuseafterdef.nim +++ b/tests/parallel/tuseafterdef.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:refc" errormsg: "(k)..(k) not disjoint from (k)..(k)" - line: 23 + line: 24 action: compile """ diff --git a/tests/parallel/twaitany.nim b/tests/parallel/twaitany.nim index b58cadd86fa97..d57c5f40fc16f 100644 --- a/tests/parallel/twaitany.nim +++ b/tests/parallel/twaitany.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" output: '''true''' """ diff --git a/tests/parser/t12274.nim b/tests/parser/t12274.nim index 40c85f1585782..6b7c9f55aec65 100644 --- a/tests/parser/t12274.nim +++ b/tests/parser/t12274.nim @@ -1,3 +1,7 @@ +discard """ + joinable: false +""" + var s: seq[int] s.add block: let i = 1 diff --git a/tests/pragmas/t12640.nim b/tests/pragmas/t12640.nim index 60177d034d8c2..c85185699b08e 100644 --- a/tests/pragmas/t12640.nim +++ b/tests/pragmas/t12640.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" nimout: '''1 2 3 @@ -10,7 +11,7 @@ discard """ [1, 2, 3]''' """ - +# todo fixme it doesn't work with ORC proc doIt(a: openArray[int]) = echo a diff --git a/tests/pragmas/tnoreturn.nim b/tests/pragmas/tnoreturn.nim index 6d0466df3b754..6a58055fe5dbc 100644 --- a/tests/pragmas/tnoreturn.nim +++ b/tests/pragmas/tnoreturn.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" ccodeCheck: "\\i @'__attribute__((noreturn))' .*" action: compile """ diff --git a/tests/stdlib/mgenast.nim b/tests/stdlib/mgenast.nim index 2b5381891fcbe..b0904847ef3bd 100644 --- a/tests/stdlib/mgenast.nim +++ b/tests/stdlib/mgenast.nim @@ -31,6 +31,8 @@ macro bindme6UseExpose*(): untyped = genAst: var tst = "sometext" var ss = newStringStream("anothertext") + when defined(gcArc) or defined(gcOrc): + prepareMutation(tst) writeData(ss, tst[0].addr, 2) discard readData(ss, tst[0].addr, 2) @@ -40,6 +42,8 @@ macro bindme6UseExposeFalse*(): untyped = genAstOpt({kDirtyTemplate}, newStringStream, writeData, readData): var tst = "sometext" var ss = newStringStream("anothertext") + when defined(gcArc) or defined(gcOrc): + prepareMutation(tst) writeData(ss, tst[0].addr, 2) discard readData(ss, tst[0].addr, 2) diff --git a/tests/stdlib/tgenast.nim b/tests/stdlib/tgenast.nim index 0904b83dd1a0f..26264744bc0bb 100644 --- a/tests/stdlib/tgenast.nim +++ b/tests/stdlib/tgenast.nim @@ -1,3 +1,7 @@ +discard """ + matrix: "--mm:orc; --mm:refc" +""" + # xxx also test on js import std/genasts diff --git a/tests/stdlib/thttpclient_ssl.nim b/tests/stdlib/thttpclient_ssl.nim index 3acdacfe36974..cf0485b128ed4 100644 --- a/tests/stdlib/thttpclient_ssl.nim +++ b/tests/stdlib/thttpclient_ssl.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim $target --threads:on -d:ssl $options $file" + cmd: "nim $target --mm:refc -d:ssl $options $file" disabled: "openbsd" """ diff --git a/tests/stdlib/tjson.nim b/tests/stdlib/tjson.nim index 336558ff38c9e..3fbb4b5316c29 100644 --- a/tests/stdlib/tjson.nim +++ b/tests/stdlib/tjson.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" targets: "c cpp js" """ @@ -49,7 +50,7 @@ for i in 0 .. 10000: except: discard # memory diff should less than 4M -doAssert(abs(getOccupiedMem() - startMemory) < 4 * 1024 * 1024) +doAssert(abs(getOccupiedMem() - startMemory) < 4 * 1024 * 1024) # todo fixme doesn;t work for ORC # test `$` diff --git a/tests/stdlib/tmitems.nim b/tests/stdlib/tmitems.nim index c0ced7cab4072..171604e33a092 100644 --- a/tests/stdlib/tmitems.nim +++ b/tests/stdlib/tmitems.nim @@ -62,6 +62,7 @@ block: block: var x = "foobar" + prepareMutation(x) var y = cast[cstring](addr x[0]) for c in y.mitems: inc c @@ -75,6 +76,7 @@ block: block: var x = "foobar" + prepareMutation(x) var y = cast[cstring](addr x[0]) for i, c in y.mpairs: inc c, i diff --git a/tests/stdlib/tstdlib_various.nim b/tests/stdlib/tstdlib_various.nim index bc90d6ef48228..4efc5a57edb76 100644 --- a/tests/stdlib/tstdlib_various.nim +++ b/tests/stdlib/tstdlib_various.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--mm:refc" output: ''' abc def diff --git a/tests/stdlib/tstring.nim b/tests/stdlib/tstring.nim index 3e2ccb2518179..ce309626e9bf7 100644 --- a/tests/stdlib/tstring.nim +++ b/tests/stdlib/tstring.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" targets: "c cpp js" """ diff --git a/tests/stdlib/twchartoutf8.nim b/tests/stdlib/twchartoutf8.nim index a6602e3e39812..3182ee46afc71 100644 --- a/tests/stdlib/twchartoutf8.nim +++ b/tests/stdlib/twchartoutf8.nim @@ -66,8 +66,7 @@ else: #RFC-2781 "UTF-16, an encoding of ISO 10646" - var wc: WideCString - unsafeNew(wc, 1024 * 4 + 2) + var wc: WideCString = newWideCString(1024 * 2) #U+0000 to U+D7FF #skip the U+0000 diff --git a/tests/system/tdeepcopy.nim b/tests/system/tdeepcopy.nim index 383d2e8d134ef..92ba48115b6c3 100644 --- a/tests/system/tdeepcopy.nim +++ b/tests/system/tdeepcopy.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc; --mm:orc --deepcopy:on" output: "ok" """ diff --git a/tests/template/twrongmapit.nim b/tests/template/twrongmapit.nim index 5b8663cf9a23e..13f53d1192dbb 100644 --- a/tests/template/twrongmapit.nim +++ b/tests/template/twrongmapit.nim @@ -1,4 +1,5 @@ discard """ + disabled: true output: "####" """ # unfortunately our tester doesn't support multiple lines of compiler diff --git a/tests/threads/tjsthreads.nim b/tests/threads/tjsthreads.nim index 1085d91579758..2a8ff60fb8606 100644 --- a/tests/threads/tjsthreads.nim +++ b/tests/threads/tjsthreads.nim @@ -1,6 +1,6 @@ discard """ targets: "c cpp js" - matrix: "--threads" + matrix: "--threads:on" """ echo 123 diff --git a/tests/threads/tonthreadcreation.nim b/tests/threads/tonthreadcreation.nim index f588a21c90f21..0652d79f873d2 100644 --- a/tests/threads/tonthreadcreation.nim +++ b/tests/threads/tonthreadcreation.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc; --mm:orc --deepcopy:on" output: '''some string here dying some string here''' """ diff --git a/tests/typerel/t4799_1.nim b/tests/typerel/t4799_1.nim index 74012190b844a..03d2a0cfaacf6 100644 --- a/tests/typerel/t4799_1.nim +++ b/tests/typerel/t4799_1.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" targets: "c cpp" outputsub: '''ObjectAssignmentDefect''' exitcode: "1" diff --git a/tests/typerel/t4799_2.nim b/tests/typerel/t4799_2.nim index f97b8962233c5..ef8571f2562ee 100644 --- a/tests/typerel/t4799_2.nim +++ b/tests/typerel/t4799_2.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" targets: "c cpp" outputsub: '''ObjectAssignmentDefect''' exitcode: "1" diff --git a/tests/typerel/t4799_3.nim b/tests/typerel/t4799_3.nim index 6102b69cc637a..26258b98351f3 100644 --- a/tests/typerel/t4799_3.nim +++ b/tests/typerel/t4799_3.nim @@ -1,4 +1,5 @@ discard """ + matrix: "--mm:refc" targets: "c cpp" outputsub: '''ObjectAssignmentDefect''' exitcode: "1" diff --git a/tests/typerel/ttypedesc_as_genericparam1.nim b/tests/typerel/ttypedesc_as_genericparam1.nim index 3998a6a5fa60a..8fdcf217e4428 100644 --- a/tests/typerel/ttypedesc_as_genericparam1.nim +++ b/tests/typerel/ttypedesc_as_genericparam1.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:refc" errormsg: "type mismatch: got " - line: 6 + line: 7 """ # bug #3079, #1146 -echo repr(int) +echo repr(int) \ No newline at end of file diff --git a/tests/typerel/ttypedesc_as_genericparam1_orc.nim b/tests/typerel/ttypedesc_as_genericparam1_orc.nim new file mode 100644 index 0000000000000..0ee4d8f92563e --- /dev/null +++ b/tests/typerel/ttypedesc_as_genericparam1_orc.nim @@ -0,0 +1 @@ +doAssert repr(int) == "int" \ No newline at end of file diff --git a/tests/typerel/ttypedesc_as_genericparam2.nim b/tests/typerel/ttypedesc_as_genericparam2.nim index ea06606f93bd0..882f66584da61 100644 --- a/tests/typerel/ttypedesc_as_genericparam2.nim +++ b/tests/typerel/ttypedesc_as_genericparam2.nim @@ -1,6 +1,7 @@ discard """ + matrix: "--mm:refc" errormsg: "'repr' doesn't support 'void' type" - line: 9 + line: 10 """ # bug #2879