Skip to content

Commit daad06b

Browse files
authored
closes #13426; adds a test case (#23642)
closes #13426
1 parent afa5c5a commit daad06b

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

tests/template/t13426.nim

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
discard """
2+
cmd: "nim check --hints:off $file"
3+
errormsg: ""
4+
nimout: '''
5+
t13426.nim(81, 6) template/generic instantiation of `fun` from here
6+
t13426.nim(80, 24) Error: type mismatch: got <int> but expected 'string'
7+
t13426.nim(81, 6) template/generic instantiation of `fun` from here
8+
t13426.nim(80, 17) Error: type mismatch: got <uint, string>
9+
but expected one of:
10+
proc `and`(x, y: uint): uint
11+
first type mismatch at position: 2
12+
required type for y: uint
13+
but expression 'high(@[1])' is of type: string
14+
proc `and`(x, y: uint64): uint64
15+
first type mismatch at position: 2
16+
required type for y: uint64
17+
but expression 'high(@[1])' is of type: string
18+
10 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them
19+
20+
expression: 1'u and high(@[1])
21+
t13426.nim(81, 6) template/generic instantiation of `fun` from here
22+
t13426.nim(80, 17) Error: expression '' has no type (or is ambiguous)
23+
t13426.nim(87, 6) template/generic instantiation of `fun` from here
24+
t13426.nim(86, 22) Error: type mismatch: got <int> but expected 'string'
25+
t13426.nim(87, 6) template/generic instantiation of `fun` from here
26+
t13426.nim(86, 15) Error: type mismatch: got <int literal(1), string>
27+
but expected one of:
28+
proc `and`(x, y: int): int
29+
first type mismatch at position: 2
30+
required type for y: int
31+
but expression 'high(@[1])' is of type: string
32+
proc `and`(x, y: int16): int16
33+
first type mismatch at position: 2
34+
required type for y: int16
35+
but expression 'high(@[1])' is of type: string
36+
proc `and`(x, y: int32): int32
37+
first type mismatch at position: 2
38+
required type for y: int32
39+
but expression 'high(@[1])' is of type: string
40+
proc `and`(x, y: int64): int64
41+
first type mismatch at position: 2
42+
required type for y: int64
43+
but expression 'high(@[1])' is of type: string
44+
proc `and`(x, y: int8): int8
45+
first type mismatch at position: 2
46+
required type for y: int8
47+
but expression 'high(@[1])' is of type: string
48+
proc `and`(x, y: uint): uint
49+
first type mismatch at position: 2
50+
required type for y: uint
51+
but expression 'high(@[1])' is of type: string
52+
proc `and`(x, y: uint16): uint16
53+
first type mismatch at position: 2
54+
required type for y: uint16
55+
but expression 'high(@[1])' is of type: string
56+
proc `and`(x, y: uint32): uint32
57+
first type mismatch at position: 2
58+
required type for y: uint32
59+
but expression 'high(@[1])' is of type: string
60+
proc `and`(x, y: uint64): uint64
61+
first type mismatch at position: 2
62+
required type for y: uint64
63+
but expression 'high(@[1])' is of type: string
64+
proc `and`(x, y: uint8): uint8
65+
first type mismatch at position: 2
66+
required type for y: uint8
67+
but expression 'high(@[1])' is of type: string
68+
2 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them
69+
70+
expression: 1 and high(@[1])
71+
t13426.nim(87, 6) template/generic instantiation of `fun` from here
72+
t13426.nim(86, 15) Error: expression '' has no type (or is ambiguous)
73+
'''
74+
"""
75+
76+
# bug # #13426
77+
block:
78+
template bar(t): string = high(t)
79+
proc fun[A](key: A) =
80+
var h = 1'u and bar(@[1])
81+
fun(0)
82+
83+
block:
84+
template bar(t): string = high(t)
85+
proc fun[A](key: A) =
86+
var h = 1 and bar(@[1])
87+
fun(0)

0 commit comments

Comments
 (0)