forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes nim-lang#6013, closes nim-lang#7009, closes nim-lang#9190, closes nim-lang#12487, closes nim-lang#12831, closes nim-lang#13184, closes nim-lang#13252, closes nim-lang#14860, closes nim-lang#14877, closes nim-lang#14894, closes nim-lang#14917, closes nim-lang#16153, closes nim-lang#16439, closes nim-lang#17779, closes nim-lang#18074, closes nim-lang#18202, closes nim-lang#18314, closes nim-lang#18648, closes nim-lang#19063, closes nim-lang#19446, closes nim-lang#20065, closes nim-lang#20367, closes nim-lang#22126, closes nim-lang#22820, closes nim-lang#22888, closes nim-lang#23020, closes nim-lang#23287, closes nim-lang#23510
- Loading branch information
Showing
27 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
block: # issue #13184 | ||
type | ||
TypeClass = uint | enum | int | ||
ArrayAlias[I: TypeClass] = array[I, int] | ||
|
||
proc test[I: TypeClass](points: ArrayAlias[I]) = | ||
discard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
discard """ | ||
action: compile | ||
targets: "cpp" | ||
matrix: "--compileOnly" | ||
""" | ||
|
||
# issue #20065 | ||
|
||
type | ||
Foo* {.importC, nodecl.} = object # doesn't matter if this is importC or importCpp | ||
value*: int64 | ||
Bar* {.importCpp, nodecl.} = object # no segfault with importC | ||
foo*: Foo | ||
|
||
discard @[Bar()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type Y* = object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type Y* = object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# issue #23510 | ||
|
||
import ./mambtype1 | ||
import ./mambtype2 | ||
|
||
proc u(d: int | int) = | ||
var r: Y #[tt.Error | ||
^ ambiguous identifier: 'Y' -- use one of the following: | ||
mambtype1.Y: Y | ||
mambtype2.Y: Y]# | ||
static: doAssert r is j.Y # because j is imported first | ||
doAssert r is j.Y | ||
|
||
u(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# issue #16439 | ||
|
||
import std/[strutils, sequtils] | ||
var data = "aaa aaa" | ||
echo data.split(" ").map(toSeq) #[tt.Error | ||
^ type mismatch: got <seq[string], template (iter: untyped): untyped>]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
discard """ | ||
output: ''' | ||
L | ||
L | ||
L | ||
L | ||
B | ||
B | ||
B | ||
B | ||
''' | ||
""" | ||
|
||
# issue #18202 | ||
|
||
type | ||
R = object | ||
S = object | ||
U = R | S | ||
|
||
L = object | ||
B = object | ||
C = B | L | ||
|
||
proc f(n: L, q: R | S) = echo "L" | ||
proc f(n: B, q: R | S) = echo "B" | ||
|
||
proc g(n: C, q: R | S) = echo (when n is L: "L" else: "B") | ||
|
||
proc h(n: L, q: U) = echo "L" | ||
proc h(n: B, q: U) = echo "B" | ||
|
||
proc j(n: C, q: U) = echo (when n is L: "L" else: "B") | ||
|
||
proc e(n: B | L, a: R) = | ||
template t(operations: untyped, fn: untyped) = fn(n, operations) | ||
|
||
# Work as expected | ||
t(a, f) | ||
t(a, g) | ||
t(a, j) | ||
|
||
# Error: type mismatch: got <R, proc [*missing parameters*](n: B, q: U) | proc [*missing parameters*](n: L, q: U)> | ||
t(a, h) | ||
|
||
e(L(), R()) | ||
e(B(), R()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# issue #14860 | ||
|
||
type | ||
Dummie = object | ||
|
||
iterator `[]`(d: Dummie, a, b: int): int = discard | ||
|
||
let d = Dummie() | ||
|
||
for s in d[0, 1]: discard # error here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# issue #19063 | ||
|
||
iterator items[T]*(s: seq[T]): T = #[tt.Error | ||
^ invalid indentation; an export marker '*' follows the declared identifier]# | ||
for i in system.items(s): | ||
yield i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# issue #12831 | ||
|
||
import std/[macros, strutils] | ||
|
||
macro dumpRepr(x: typed): untyped = | ||
result = newLit(x.treeRepr & "\n") | ||
doAssert dumpRepr(`$`).startsWith("ClosedSymChoice") | ||
|
||
# issue #19446 | ||
|
||
macro typedVarargs(x: varargs[typed]): untyped = | ||
result = newLit($x[0].kind) | ||
|
||
macro typedSingle(x: typed): untyped = | ||
result = newLit($x.kind) | ||
|
||
doAssert typedSingle(len) == "nnkClosedSymChoice" | ||
doAssert typedVarargs(len) == "nnkClosedSymChoice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
block: # issue #18314, case 1 | ||
type | ||
A = ref object of RootObj | ||
B = ref object of A | ||
C = ref object of B | ||
|
||
proc foo[T: A](a: T) = echo "got A" | ||
proc foo[T: B](b: T) = echo "got B" | ||
|
||
var c = C() | ||
foo(c) | ||
|
||
block: # issue #18314, case 2 | ||
type | ||
A = ref object of RootObj | ||
B = ref object of A | ||
C = ref object of B | ||
|
||
proc foo[T: A](a: T) = echo "got A" | ||
proc foo(b: B) = echo "got B" | ||
|
||
var c = C() | ||
foo(c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import std/options | ||
|
||
type | ||
Address* = object | ||
port*: int | ||
|
||
Node* = ref object | ||
address*: Option[Address] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# issue #22126 | ||
|
||
func foo[T](arr: openArray[T], idx: Natural = arr.high): int = # missed conversion: `Natural(arr.high)` | ||
if idx == 0: | ||
return 0 | ||
foo(arr, idx - 1) | ||
|
||
let arr = [0, 1, 2] | ||
|
||
doAssert foo(arr) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# issue #23020 | ||
|
||
proc n[T: bool](k: int | int) = | ||
#static: | ||
# doAssert T is bool | ||
# doAssert T isnot int | ||
|
||
# And runtime | ||
block: | ||
doAssert T is bool | ||
doAssert T isnot int | ||
|
||
n[int](0) #[tt.Error | ||
^ type mismatch: got <int literal(0)>]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# issue #22820 | ||
|
||
{.push raises: [].} | ||
|
||
import | ||
"."/[msugarcrash1] | ||
|
||
import | ||
std/[options, sugar] | ||
|
||
var closestNodes: seq[Node] | ||
for cn in closestNodes: | ||
discard cn.address.map(a => a.port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# issue #22888 | ||
|
||
proc dummy*[T: SomeNumber](a: T, b: T = 2.5): T = #[tt.Error | ||
^ type mismatch: got <float64> but expected 'int']# | ||
result = a | ||
|
||
echo dummy(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
block: # issue #6013 | ||
type | ||
n16 = range[0'i16..high(int16)] | ||
SomeObj = ref object | ||
|
||
proc doSomethingMore(idOrObj: n16 or SomeObj) = | ||
discard | ||
|
||
proc doSomething(idOrObj: n16 or SomeObj) = | ||
doSomethingMore(idOrObj) # Error: type mismatch: got (int16) | ||
|
||
doSomething(0.n16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# issue #17779 | ||
|
||
{.experimental: "dotOperators".} | ||
|
||
type | ||
Flag = enum | ||
A | ||
|
||
Flags = set[Flag] | ||
|
||
template `.=`*(flags: Flags, key: Flag, val: bool) = | ||
if val: flags.incl key else: flags.excl key | ||
|
||
var flags: Flags | ||
|
||
flags.A = 123 #[tt.Error | ||
^ undeclared field: 'A=' for type tmismatch.Flags [type declared in tmismatch.nim(9, 5)]]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.