mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 23:35:22 +00:00
Fix #4737
This commit is contained in:
committed by
Andreas Rumpf
parent
16eb4b1fee
commit
a6006e56a7
21
tests/errmsgs/tconceptconstraint.nim
Normal file
21
tests/errmsgs/tconceptconstraint.nim
Normal file
@@ -0,0 +1,21 @@
|
||||
discard """
|
||||
errormsg: "cannot instantiate B"
|
||||
line: 20
|
||||
nimout: '''
|
||||
got: (type string)
|
||||
but expected: (T: A)
|
||||
'''
|
||||
"""
|
||||
|
||||
type
|
||||
A = concept c
|
||||
advance(c)
|
||||
|
||||
B[T: A] = object
|
||||
child: ref B[T]
|
||||
|
||||
proc advance(x: int): int = x + 1
|
||||
|
||||
var a: B[int]
|
||||
var b: B[string]
|
||||
|
||||
15
tests/errmsgs/tgenericconstraint.nim
Normal file
15
tests/errmsgs/tgenericconstraint.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
discard """
|
||||
errormsg: "cannot instantiate B"
|
||||
line: 14
|
||||
nimout: '''
|
||||
got: (type int)
|
||||
but expected: (T: string or float)
|
||||
'''
|
||||
"""
|
||||
|
||||
type
|
||||
B[T: string|float] = object
|
||||
child: ref B[T]
|
||||
|
||||
var b: B[int]
|
||||
|
||||
Reference in New Issue
Block a user