mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 14:32:53 +00:00
* fixes #21801; object field initialization with overloaded functions * use the correct type
This commit is contained in:
@@ -227,8 +227,8 @@ proc isRecursiveType(t: PType, cycleDetector: var IntSet): bool =
|
||||
|
||||
proc fitDefaultNode(c: PContext, n: PNode): PType =
|
||||
let expectedType = if n[^2].kind != nkEmpty: semTypeNode(c, n[^2], nil) else: nil
|
||||
let oldType = n[^1].typ
|
||||
n[^1] = semConstExpr(c, n[^1], expectedType = expectedType)
|
||||
let oldType = n[^1].typ
|
||||
n[^1].flags.incl nfSem
|
||||
if n[^2].kind != nkEmpty:
|
||||
if expectedType != nil and oldType != expectedType:
|
||||
|
||||
@@ -591,6 +591,29 @@ template main {.dirty.} =
|
||||
|
||||
mainSync()
|
||||
|
||||
block: # bug #21801
|
||||
func evaluate(i: int): float =
|
||||
0.0
|
||||
|
||||
func evaluate(): float =
|
||||
0.0
|
||||
|
||||
type SearchOptions = object
|
||||
evaluation: proc(): float = evaluate
|
||||
|
||||
block:
|
||||
func evaluate(): float =
|
||||
0.0
|
||||
|
||||
type SearchOptions = object
|
||||
evaluation: proc(): float = evaluate
|
||||
|
||||
block:
|
||||
func evaluate(i: int): float =
|
||||
0.0
|
||||
|
||||
type SearchOptions = object
|
||||
evaluation = evaluate
|
||||
|
||||
static: main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user