From 15d1fafc710f3f21a18f8d1ac95c7ccc971ebd01 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 5 Aug 2026 22:27:37 +0800 Subject: [PATCH] progress --- compiler/semtypinst.nim | 14 +++++++++++--- tests/generics/t24848.nim | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 8bff73768d..03ded02dd0 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -12,7 +12,7 @@ import std / tables import ast, astalgo, msgs, types, magicsys, semdata, renderer, options, - lineinfos, modulegraphs, layeredtable + lineinfos, modulegraphs, layeredtable, typeallowed when defined(nimPreviewSlimSystem): import std/assertions @@ -296,9 +296,17 @@ proc replaceTypeVarsN(cl: var TReplTypeVars, n: PNode; start=0; expectedType: PT replaceTypeVarsS(cl, n.sym, replaceTypeVarsT(cl, n.sym.typ)) if result.sym.kind == skField and (cl.owner == nil or result.sym.owner == cl.owner): - if not cl.allowMetaTypes and result.typ != nil and result.typ.isMetaType: + let invalidType = + if not cl.allowMetaTypes and result.typ != nil and result.typ.isMetaType and + result.sym.owner != nil and result.sym.owner.kind == skType: + typeAllowed(result.typ, skVar, cl.c, {taProcContextIsNotMacro}) + else: + nil + # Constrained types can remain unresolved during overload matching. Only + # reject the type-valued storage that can reach code generation (#24848). + if invalidType != nil and invalidType.kind == tyTypeDesc: localError(cl.c.config, result.info, - "'" & result.typ.typeToString & "' is not a concrete type") + "'" & invalidType.typeToString & "' is not a concrete type") result.typ = errorType(cl.c) result.sym.typ = result.typ if result.sym.ast != nil: diff --git a/tests/generics/t24848.nim b/tests/generics/t24848.nim index 453f66ea10..1c1ef08b15 100644 --- a/tests/generics/t24848.nim +++ b/tests/generics/t24848.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "'array[0..0, typedesc[R[system.int]]]' is not a concrete type" + errormsg: "'typedesc[R[system.int]]' is not a concrete type" line: 8 """