mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 03:02:31 +00:00
* fixes #20900; Calling template through from generic function across module fails to build
* sanother way
(cherry picked from commit 16f42084d3)
This commit is contained in:
@@ -82,6 +82,7 @@ proc semConstrField(c: PContext, flags: TExprFlags,
|
||||
var initValue = semExprFlagDispatched(c, assignment[1], flags, field.typ)
|
||||
if initValue != nil:
|
||||
initValue = fitNodeConsiderViewType(c, field.typ, initValue, assignment.info)
|
||||
initValue.flags.incl nfSkipFieldChecking
|
||||
assignment[0] = newSymNode(field)
|
||||
assignment[1] = initValue
|
||||
assignment.flags.incl nfSem
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
type
|
||||
Noice* = object
|
||||
hidden: int
|
||||
|
||||
|
||||
template jjj*: Noice =
|
||||
Noice(hidden: 15)
|
||||
Noice(hidden: 15)
|
||||
|
||||
type Opt* = object
|
||||
o: int
|
||||
|
||||
template none*(O: type Opt): Opt = Opt(o: 0)
|
||||
|
||||
@@ -7,3 +7,7 @@ proc someGeneric(_: type) =
|
||||
doAssert $jjj() == "(hidden: 15)" # fails: "Error: the field 'hidden' is not accessible."
|
||||
|
||||
someGeneric(int)
|
||||
|
||||
# bug #20900
|
||||
proc c(y: int | int, w: Opt = Opt.none) = discard
|
||||
c(0)
|
||||
|
||||
Reference in New Issue
Block a user