diff --git a/compiler/ast.nim b/compiler/ast.nim index 4ef5c0cbbb49b..a015fd259506c 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1457,7 +1457,7 @@ proc findMetaTypeCompOrNil*(t: PType): PType= if t == nil: return nil if tfHasMeta in t.flags: - return t + result = t if t.size == szIllegalRecursion: return nil let tmp = t.size @@ -1465,25 +1465,23 @@ proc findMetaTypeCompOrNil*(t: PType): PType= case t.kind of tyMetaTypes, tyNone: result = t - result.flags.incl tfHasMeta of tyStatic: if t.n == nil: result = t - result.flags.incl tfHasMeta of tySequence, tySet, tyArray, tyOpenArray, tyVar, tyLent, tyPtr, tyRef, tyProc, tyGenericInvocation, tyGenericInst, tyAlias, tySink, tyOwned: let start = ord(t.kind in {tyGenericInvocation, tyGenericInst}) for i in start.. 0 diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 28e6aa18e8fff..24da45b8e230b 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1604,8 +1604,7 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = # like: mydata.seq if s.typ.kind == tyArray and s.typ.len == 2: discard - elif s.typ.kind in {tyOpenArray, tyVarargs} and s.typ.len == 1: - # XXX investigate why `tySequence` cannot be added here for now. + elif s.typ.kind in {tyOpenArray, tyVarargs, tySequence} and s.typ.len == 1: discard else: rawAddSon(s.typ, newTypeS(tyNone, c)) diff --git a/tests/concepts/tconceptsv2.nim b/tests/concepts/tconceptsv2.nim new file mode 100644 index 0000000000000..893ad9b59d38b --- /dev/null +++ b/tests/concepts/tconceptsv2.nim @@ -0,0 +1,22 @@ +discard """ +action: "run" +output: ''' +A[array[0..0, int]] +A[seq[int]] +''' +""" +type + SomethingLike[T] = concept + proc len(s: Self): int + proc `[]`(s: Self; index: int): T + + A[T] = object + x: T + +proc initA*(x: SomethingLike): auto = + A[type x](x: x) + +var a: array[1, int] +var s: seq[int] +echo typeof(initA(a)) +echo typeof(initA(s)) diff --git a/tests/generics/tmetafield.nim b/tests/generics/tmetafield.nim index cf30a936d9d46..ee1ec8d94be8d 100644 --- a/tests/generics/tmetafield.nim +++ b/tests/generics/tmetafield.nim @@ -1,5 +1,6 @@ discard """ cmd: "nim check $options $file" + matrix: "--hints:off" action: "reject" nimout: ''' tmetafield.nim(26, 5) Error: 'proc' is not a concrete type; for a callback without parameters use 'proc()'