mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
fixes #25252
(cherry picked from commit d54b5f3ae1)
This commit is contained in:
@@ -533,7 +533,7 @@ proc semTuple(c: PContext, n: PNode, prev: PType): PType =
|
||||
typ = a[^1].typ
|
||||
else:
|
||||
fitDefaultNode(c, a[^1], typ)
|
||||
typ = a[^1].typ
|
||||
typ = a[^1].typ.skipIntLit(c.idgen)
|
||||
elif a[^2].kind != nkEmpty:
|
||||
typ = semTypeNode(c, a[^2], nil)
|
||||
if c.graph.config.isDefined("nimPreviewRangeDefault") and typ.skipTypes(abstractInst).kind == tyRange:
|
||||
@@ -905,7 +905,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||
typ = n[^1].typ
|
||||
else:
|
||||
fitDefaultNode(c, n[^1], typ)
|
||||
typ = n[^1].typ
|
||||
typ = n[^1].typ.skipIntLit(c.idgen)
|
||||
propagateToOwner(rectype, typ)
|
||||
elif n[^2].kind == nkEmpty:
|
||||
localError(c.config, n.info, errTypeExpected)
|
||||
|
||||
@@ -280,7 +280,7 @@ proc replaceTypeVarsN(cl: var TReplTypeVars, n: PNode; start=0; expectedType: PT
|
||||
(cl.owner == nil or result.sym.owner == cl.owner):
|
||||
# instantiate default value of object/tuple field
|
||||
cl.c.fitDefaultNode(cl.c, result.sym.ast, result.sym.typ)
|
||||
result.sym.typ = result.sym.ast.typ
|
||||
result.sym.typ = result.sym.ast.typ.skipIntLit(cl.c.idgen)
|
||||
# sym type can be nil if was gensym created by macro, see #24048
|
||||
if result.sym.typ != nil and result.sym.typ.kind == tyVoid:
|
||||
# don't add the 'void' field
|
||||
|
||||
@@ -375,7 +375,7 @@ template main {.dirty.} =
|
||||
type
|
||||
Color = enum
|
||||
Red, Blue, Yellow
|
||||
|
||||
|
||||
type
|
||||
ObjectVarint3 = object
|
||||
case kind: Color = Blue
|
||||
@@ -663,7 +663,7 @@ template main {.dirty.} =
|
||||
|
||||
when not(T is void):
|
||||
v.vResultPrivate
|
||||
|
||||
|
||||
type R = Result[int, string]
|
||||
|
||||
proc testAssignResult() =
|
||||
@@ -811,3 +811,17 @@ template main {.dirty.} =
|
||||
|
||||
static: main()
|
||||
main()
|
||||
|
||||
type
|
||||
Thing = object
|
||||
a: int = 100 # this is fine
|
||||
b = 100 # this is not
|
||||
|
||||
proc overloaded[T: SomeSignedInt](x: T) = discard
|
||||
proc overloaded[T: SomeUnsignedInt](x: T) = discard
|
||||
proc overloaded[T: object](x: T) =
|
||||
for val in fields(x):
|
||||
var v: typeof(val)
|
||||
overloaded(v)
|
||||
|
||||
overloaded(Thing())
|
||||
|
||||
Reference in New Issue
Block a user