diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index 467f015d8..d7b1f2daa 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -1085,7 +1085,13 @@ proc inst(g: ModuleGraph; c: PContext; t: PType; kind: TTypeAttachedOp; idgen: I let op = getAttachedOp(g, t, kind) if op != nil and op.ast != nil and op.ast.isGenericRoutine: if t.typeInst != nil: - var a = TLiftCtx(info: info, g: g, kind: kind, c: c, idgen: idgen) + var a: TLiftCtx + a.info = info + a.g = g + a.kind = kind + a.c = c + a.idgen = idgen + let opInst = instantiateGeneric(a, op, t, t.typeInst) if opInst.ast != nil: patchBody(g, c, opInst.ast, info, a.idgen) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 3f028a52f..e7bca08bc 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -343,8 +343,7 @@ proc addDeclAt*(c: PContext; scope: PScope, sym: PSym, info: TLineInfo) = if sym.name.s == "_": return let conflict = scope.addUniqueSym(sym) if conflict != nil: - if sym.kind == skModule and conflict.kind == skModule and - sym.position == conflict.position: + if sym.kind == skModule and conflict.kind == skModule and sym.owner == conflict.owner: # e.g.: import foo; import foo # xxx we could refine this by issuing a different hint for the case # where a duplicate import happens inside an include. diff --git a/compiler/main.nim b/compiler/main.nim index ff870a14a..d37d26478 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -71,13 +71,6 @@ proc commandGenDepend(graph: ModuleGraph) = let project = graph.config.projectFull writeDepsFile(graph) generateDot(graph, project) - - # dot in graphivz tool kit is required - let graphvizDotPath = findExe("dot") - if graphvizDotPath.len == 0: - quit("gendepend: Graphviz's tool dot is required," & - "see https://graphviz.org/download for downloading") - execExternalProgram(graph.config, "dot -Tpng -o" & changeFileExt(project, "png").string & ' ' & changeFileExt(project, "dot").string) diff --git a/compiler/nodejs.nim b/compiler/nodejs.nim index c1feb196a..283643e8d 100644 --- a/compiler/nodejs.nim +++ b/compiler/nodejs.nim @@ -7,4 +7,4 @@ proc findNodeJs*(): string {.inline.} = result = findExe("node") if result.len == 0: echo "Please install NodeJS first, see https://nodejs.org/en/download" - raise newException(IOError, "NodeJS not found in PATH") + raise newException(IOError, "NodeJS not found in PATH: " & result) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index cfa34fcdc..9cf206b4c 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -998,7 +998,7 @@ proc afterCallActions(c: PContext; n, orig: PNode, flags: TExprFlags; expectedTy fixAbstractType(c, result) analyseIfAddressTakenInCall(c, result) if callee.magic != mNone: - result = magicsAfterOverloadResolution(c, result, flags, expectedType) + result = magicsAfterOverloadResolution(c, result, flags) when false: if result.typ != nil and not (result.typ.kind == tySequence and result.typ[0].kind == tyEmpty): @@ -2206,7 +2206,7 @@ proc semQuoteAst(c: PContext, n: PNode): PNode = dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[0], getSysSym(c.graph, n.info, "typed").newSymNode, c.graph.emptyNode) for i in 1.. 0 if we are in inlining context (copy vars) - isIntroducingNewLocalVars: bool # true if we are in `introducingNewLocalVars` (don't transform yields) contSyms, breakSyms: seq[PSym] # to transform 'continue' and 'break' deferDetected, tooEarly: bool graph: ModuleGraph @@ -451,9 +450,7 @@ proc transformYield(c: PTransf, n: PNode): PNode = result.add(c.transCon.forLoopBody) else: # we need to introduce new local variables: - c.isIntroducingNewLocalVars = true # don't transform yields when introducing new local vars result.add(introduceNewLocalVars(c, c.transCon.forLoopBody)) - c.isIntroducingNewLocalVars = false for idx in 0 ..< result.len: var changeNode = result[idx] @@ -1039,7 +1036,7 @@ proc transform(c: PTransf, n: PNode): PNode = else: result = transformSons(c, n) of nkYieldStmt: - if c.inlining > 0 and not c.isIntroducingNewLocalVars: + if c.inlining > 0: result = transformYield(c, n) else: result = transformSons(c, n) diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 937d4b095..be7938e53 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1909,8 +1909,7 @@ proc genVarSection(c: PCtx; n: PNode) = c.genAdditionalCopy(a[2], opcWrDeref, tmp, 0, val) c.freeTemp(val) c.freeTemp(tmp) - elif not importcCondVar(s) and not (s.typ.kind == tyProc and s.typ.callConv == ccClosure) and - sfPure notin s.flags: # fixes #10938 + elif not importcCondVar(s) and not (s.typ.kind == tyProc and s.typ.callConv == ccClosure): # fixes #10938 # there is a pre-existing issue with closure types in VM # if `(var s: proc () = default(proc ()); doAssert s == nil)` works for you; # you might remove the second condition. diff --git a/doc/advopt.txt b/doc/advopt.txt index 4db89062b..122a7c6ea 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -172,6 +172,6 @@ Advanced options: --useVersion:1.0|1.2|1.6 emulate Nim version X of the Nim compiler, for testing --benchmarkVM:on|off turn benchmarking of VM code with cpuTime() on|off --profileVM:on|off turn compile time VM profiler on|off - --sinkInference:on|off turn sink parameter inference on|off (default: off) + --sinkInference:on|off turn sink parameter inference on|off (default: on) --panics:on|off turn panics into process terminations (default: off) --deepcopy:on|off enable 'system.deepCopy' for ``--mm:arc|orc`` diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 138f2d9ec..70af466d9 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -408,16 +408,6 @@ const unitWeights: array[FixedTimeUnit, int64] = [ 7 * secondsInDay * 1e9.int64, ] -when (NimMajor, NimMinor) >= (1, 4): - # Newer versions of Nim don't track defects - {.pragma: parseFormatRaises, raises: [TimeParseError, TimeFormatParseError].} - {.pragma: parseRaises, raises: [TimeParseError].} -else: - # Still track when using older versions - {.pragma: parseFormatRaises, raises: [TimeParseError, TimeFormatParseError, Defect].} - {.pragma: parseRaises, raises: [TimeParseError, Defect].} - - # # Helper procs # @@ -2144,7 +2134,8 @@ proc format*(time: Time, f: static[string], zone: Timezone = local()): string result = time.inZone(zone).format(f2) proc parse*(input: string, f: TimeFormat, zone: Timezone = local(), - loc: DateTimeLocale = DefaultLocale): DateTime {.parseRaises.} = + loc: DateTimeLocale = DefaultLocale): DateTime + {.raises: [TimeParseError, Defect].} = ## Parses `input` as a `DateTime` using the format specified by `f`. ## If no UTC offset was parsed, then `input` is assumed to be specified in ## the `zone` timezone. If a UTC offset was parsed, the result will be @@ -2187,7 +2178,8 @@ proc parse*(input: string, f: TimeFormat, zone: Timezone = local(), result = toDateTime(parsed, zone, f, input) proc parse*(input, f: string, tz: Timezone = local(), - loc: DateTimeLocale = DefaultLocale): DateTime {.parseFormatRaises.} = + loc: DateTimeLocale = DefaultLocale): DateTime + {.raises: [TimeParseError, TimeFormatParseError, Defect].} = ## Shorthand for constructing a `TimeFormat` and using it to parse ## `input` as a `DateTime`. ## @@ -2200,12 +2192,14 @@ proc parse*(input, f: string, tz: Timezone = local(), result = input.parse(dtFormat, tz, loc = loc) proc parse*(input: string, f: static[string], zone: Timezone = local(), - loc: DateTimeLocale = DefaultLocale): DateTime {.parseRaises.} = + loc: DateTimeLocale = DefaultLocale): + DateTime {.raises: [TimeParseError, Defect].} = ## Overload that validates `f` at compile time. const f2 = initTimeFormat(f) result = input.parse(f2, zone, loc = loc) -proc parseTime*(input, f: string, zone: Timezone): Time {.parseFormatRaises.} = +proc parseTime*(input, f: string, zone: Timezone): Time + {.raises: [TimeParseError, TimeFormatParseError, Defect].} = ## Shorthand for constructing a `TimeFormat` and using it to parse ## `input` as a `DateTime`, then converting it a `Time`. ## @@ -2217,7 +2211,7 @@ proc parseTime*(input, f: string, zone: Timezone): Time {.parseFormatRaises.} = parse(input, f, zone).toTime() proc parseTime*(input: string, f: static[string], zone: Timezone): Time - {.parseRaises.} = + {.raises: [TimeParseError, Defect].} = ## Overload that validates `format` at compile time. const f2 = initTimeFormat(f) result = input.parse(f2, zone).toTime() diff --git a/tests/arc/tcaseobj.nim b/tests/arc/tcaseobj.nim index 26c122384..d52833e4d 100644 --- a/tests/arc/tcaseobj.nim +++ b/tests/arc/tcaseobj.nim @@ -269,64 +269,3 @@ proc bug20305 = echo x.pChildren bug20305() - -# bug #21023 -block: - block: - type - MGErrorKind = enum - mgeUnexpected, mgeNotFound - - type Foo = object - kind: MGErrorKind - ex: Exception - - type Boo = object - a: seq[int] - - type - Result2 = object - case o: bool - of false: - e: Foo - of true: - v: Boo - - proc startSessionSync(): Result2 = - return Result2(o: true) - - proc mainSync = - let ff = startSessionSync() - doAssert ff.o == true - - mainSync() - - block: - type - MGErrorKind = enum - mgeUnexpected, mgeNotFound - - type Foo = object - kind: MGErrorKind - ex: Exception - - type Boo = object - a: seq[int] - - type - Result2 = object - case o: bool - of false: - e: Foo - of true: - v: Boo - s: int - - proc startSessionSync(): Result2 = - return Result2(o: true, s: 12) - - proc mainSync = - let ff = startSessionSync() - doAssert ff.s == 12 - - mainSync() diff --git a/tests/errmsgs/t16654.nim b/tests/errmsgs/t16654.nim deleted file mode 100644 index 749707c06..000000000 --- a/tests/errmsgs/t16654.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - cmd: "nim check $options $file" - errormsg: "type mismatch: got but expected 'float'" -""" - -when true: # bug #16654 - func fn[T](a: T, op: proc(a: T): float) = discard - proc main() = - let v = 1 - proc bar(r: auto): auto = v - fn(1, bar) - main() diff --git a/tests/generics/tgeneric0.nim b/tests/generics/tgeneric0.nim index b5e1c4bb4..44c34917d 100644 --- a/tests/generics/tgeneric0.nim +++ b/tests/generics/tgeneric0.nim @@ -153,16 +153,3 @@ proc unzip*[T,U](xs: List[tuple[t: T, u: U]]): (List[T], List[U]) = discard proc unzip2*[T,U](xs: List[(T,U)]): (List[T], List[U]) = discard -type - AtomicType = pointer|ptr|int - - Atomic[T: AtomicType] = distinct T - - Block[T: AtomicType] = object - - AtomicContainer[T: AtomicType] = object - b: Atomic[ptr Block[T]] - -# bug #8295 -var x = AtomicContainer[int]() -doAssert (ptr Block[int])(x.b) == nil diff --git a/tests/generics/tgenerics_various.nim b/tests/generics/tgenerics_various.nim index 4cfa47809..37b6e43a1 100644 --- a/tests/generics/tgenerics_various.nim +++ b/tests/generics/tgenerics_various.nim @@ -262,8 +262,3 @@ proc doSomething[A, B](t: tuple[a: A, b: B]) = discard discard identity((c: 1, d: 2)) doSomething(identity((1, 2))) - -# bug #6231 -proc myProc[T, U](x: T or U) = discard - -myProc[int, string](x = 2) diff --git a/tests/import/buzz/m21496.nim b/tests/import/buzz/m21496.nim deleted file mode 100644 index 7c87e2c04..000000000 --- a/tests/import/buzz/m21496.nim +++ /dev/null @@ -1 +0,0 @@ -proc fb* = echo "buzz!" \ No newline at end of file diff --git a/tests/import/fizz/m21496.nim b/tests/import/fizz/m21496.nim deleted file mode 100644 index 834c11eae..000000000 --- a/tests/import/fizz/m21496.nim +++ /dev/null @@ -1 +0,0 @@ -proc fb* = echo "fizz!" \ No newline at end of file diff --git a/tests/import/t21496.nim b/tests/import/t21496.nim deleted file mode 100644 index 568f2ac51..000000000 --- a/tests/import/t21496.nim +++ /dev/null @@ -1,9 +0,0 @@ -discard """ - errormsg: "redefinition of 'm21496'; previous declaration here: t21496.nim(5, 12)" -""" - -import fizz/m21496, buzz/m21496 - -# bug #21496 - -m21496.fb() diff --git a/tests/iter/t21306.nim b/tests/iter/t21306.nim deleted file mode 100644 index 43fea9c80..000000000 --- a/tests/iter/t21306.nim +++ /dev/null @@ -1,114 +0,0 @@ -# bug #21306 -type - FutureState {.pure.} = enum - Pending, Finished, Cancelled, Failed - - FutureBase = ref object of RootObj - state: FutureState - error: ref CatchableError - id: uint - - Future[T] = ref object of FutureBase - closure: iterator(f: Future[T]): FutureBase {.raises: [Defect, CatchableError, Exception], gcsafe.} - value: T - -template setupFutureBase() = - new(result) - result.state = FutureState.Pending - -proc newFutureImpl[T](): Future[T] = - setupFutureBase() - -template newFuture[T](fromProc: static[string] = ""): Future[T] = - newFutureImpl[T]() - -proc internalRead[T](fut: Future[T]): T = - when T isnot void: - return fut.value - -template await[T](f: Future[T]): untyped = - when declared(chronosInternalRetFuture): - when not declaredInScope(chronosInternalTmpFuture): - var chronosInternalTmpFuture {.inject.}: FutureBase = f - else: - chronosInternalTmpFuture = f - - yield chronosInternalTmpFuture - - when T isnot void: - cast[type(f)](chronosInternalTmpFuture).internalRead() - -type - VerifierError {.pure.} = enum - Invalid - MissingParent - UnviableFork - Duplicate - ProcessingCallback = proc() {.gcsafe, raises: [Defect].} - BlockVerifier = - proc(signedBlock: int): - Future[VerifierError] {.gcsafe, raises: [Defect].} - - SyncQueueKind {.pure.} = enum - Forward, Backward - - SyncRequest[T] = object - kind: SyncQueueKind - index: uint64 - slot: uint64 - count: uint64 - item: T - - SyncResult[T] = object - request: SyncRequest[T] - data: seq[ref int] - - SyncQueue[T] = ref object - kind: SyncQueueKind - readyQueue: seq[SyncResult[T]] - blockVerifier: BlockVerifier - -iterator blocks[T](sq: SyncQueue[T], - sr: SyncResult[T]): ref int = - case sq.kind - of SyncQueueKind.Forward: - for i in countup(0, len(sr.data) - 1): - yield sr.data[i] - of SyncQueueKind.Backward: - for i in countdown(len(sr.data) - 1, 0): - yield sr.data[i] - -proc push[T](sq: SyncQueue[T]; sr: SyncRequest[T]; data: seq[ref int]; - processingCb: ProcessingCallback = nil): Future[void] {. - stackTrace: off, gcsafe.} = - iterator push_436208182(chronosInternalRetFuture: Future[void]): FutureBase {. - closure, gcsafe, raises: [Defect, CatchableError, Exception].} = - block: - template result(): auto {.used.} = - {.fatal: "You should not reference the `result` variable inside" & - " a void async proc".} - - let item = default(SyncResult[T]) - for blk in sq.blocks(item): - let res = await sq.blockVerifier(blk[]) - - var resultFuture = newFuture[void]("push") - resultFuture.closure = push_436208182 - return resultFuture - -type - SomeTPeer = ref object - score: int - -proc getSlice(): seq[ref int] = - discard - -template smokeTest(kkind: SyncQueueKind, start, finish: uint64, - chunkSize: uint64) = - var queue: SyncQueue[SomeTPeer] - var request: SyncRequest[SomeTPeer] - discard queue.push(request, getSlice()) - -for k in {SyncQueueKind.Forward}: - for item in [(uint64(1181), uint64(1399), 41'u64)]: - smokeTest(k, item[0], item[1], item[2]) \ No newline at end of file diff --git a/tests/objects/tobject_default_value.nim b/tests/objects/tobject_default_value.nim index 59af943e0..150fb0876 100644 --- a/tests/objects/tobject_default_value.nim +++ b/tests/objects/tobject_default_value.nim @@ -559,38 +559,6 @@ template main {.dirty.} = let x = default(Default) doAssert x.data is DjangoDateTime - block: - type - Result2 = object - case o: bool - of false: - e: float - of true: - v {.requiresInit.} : int = 1 - - proc startSessionSync(): Result2 = - return Result2(o: true) - - proc mainSync = - let ff = startSessionSync() - doAssert ff.v == 1 - - mainSync() - - block: - type - Result2 = object - v {.requiresInit.} : int = 1 - - proc startSessionSync(): Result2 = - return Result2() - - proc mainSync = - let ff = startSessionSync() - doAssert ff.v == 1 - - mainSync() - static: main() main() diff --git a/tests/stdlib/tmacros.nim b/tests/stdlib/tmacros.nim index 9e3ebee83..a03bcca2d 100644 --- a/tests/stdlib/tmacros.nim +++ b/tests/stdlib/tmacros.nim @@ -311,11 +311,3 @@ block: # bug #9607 doAssert echoL() == "bar" doAssert echoM() == "bar" - -block: - macro hello[T](x: T): untyped = - result = quote do: - let m: `T` = `x` - discard m - - hello(12) diff --git a/tests/stdlib/tsugar.nim b/tests/stdlib/tsugar.nim index 1b629165a..6ef3ae519 100644 --- a/tests/stdlib/tsugar.nim +++ b/tests/stdlib/tsugar.nim @@ -3,7 +3,7 @@ discard """ x + y = 30 ''' """ -import std/[sugar, algorithm, random, sets, tables, strutils, sequtils] +import std/[sugar, algorithm, random, sets, tables, strutils] import std/[syncio, assertions] type # for capture test, ref #20679 @@ -287,17 +287,6 @@ proc mainProc() = doAssertRaises(AssertionDefect): doAssert false doAssert "except AssertionDefect" in s2 - block: # bug #20704 - proc test() = - var xs, ys: seq[int] - for i in 0..5: - xs.add(i) - - xs.apply(d => ys.add(d)) - doAssert ys == @[0, 1, 2, 3, 4, 5] - - test() - static: main() mainProc() diff --git a/tests/types/ttopdowninference.nim b/tests/types/ttopdowninference.nim index cabc798ed..310dbb2ad 100644 --- a/tests/types/ttopdowninference.nim +++ b/tests/types/ttopdowninference.nim @@ -245,7 +245,7 @@ block: # bug #11777 var s: S = {1, 2} doAssert 1 in s -block: # bug #20807 +block: # regression #20807 var s: seq[string] template fail = s = @[] @@ -255,38 +255,3 @@ block: # bug #20807 test: fail() doAssert not (compiles do: let x: seq[int] = `@`[string]([])) - -block: # bug #21377 - proc b[T](v: T): seq[int] = - let x = 0 - @[] - - doAssert b(0) == @[] - -block: # bug #21377 - proc b[T](v: T): seq[T] = - let x = 0 - @[] - - doAssert b(0) == @[] - -block: # bug #21377 - proc b[T](v: T): set[bool] = - let x = 0 - {} - - doAssert b(0) == {} - -block: # bug #21377 - proc b[T](v: T): array[0, int] = - let x = 0 - [] - - doAssert b(0) == [] - -block: # bug #21377 - proc b[T](v: T): array[0, (string, string)] = - let x = 0 - {:} - - doAssert b(0) == {:} diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index 14818375d..673e3e965 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -643,16 +643,3 @@ const b = block: doAssert a == @[@[0, 1, 2], @[0, 1, 2], @[0, 1, 2]] doAssert b == @[@[0, 1, 2], @[0, 1, 2], @[0, 1, 2]] - -macro m1(s: string): int = - var ProcID {.global, compileTime.}: int - inc(ProcID) - result = newLit(ProcID) - -proc macroGlobal = - doAssert m1("Macro argument") == 1 - doAssert m1("Macro argument") == 2 - doAssert m1("Macro argument") == 3 - -static: macroGlobal() -macroGlobal()