This commit is contained in:
Andreas Rumpf 2019-05-28 22:00:01 +02:00 • committed by GitHub
commit e68adca0c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -1883,14 +1883,13 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
c.p.wasForwarded = proto != nil c.p.wasForwarded = proto != nil
maybeAddResult(c, s, n) maybeAddResult(c, s, n)
if s.kind == skMethod: semMethodPrototype(c, s, n)
if lfDynamicLib notin s.loc.flags: if lfDynamicLib notin s.loc.flags:
# no semantic checking for importc: # no semantic checking for importc:
s.ast[bodyPos] = hloBody(c, semProcBody(c, n.sons[bodyPos])) s.ast[bodyPos] = hloBody(c, semProcBody(c, n.sons[bodyPos]))
# unfortunately we cannot skip this step when in 'system.compiles' # unfortunately we cannot skip this step when in 'system.compiles'
# context as it may even be evaluated in 'system.compiles': # context as it may even be evaluated in 'system.compiles':
trackProc(c, s, s.ast[bodyPos]) trackProc(c, s, s.ast[bodyPos])
if s.kind == skMethod: semMethodPrototype(c, s, n)
else: else:
if (s.typ.sons[0] != nil and kind != skIterator) or kind == skMacro: if (s.typ.sons[0] != nil and kind != skIterator) or kind == skMacro:
addDecl(c, newSym(skUnknown, getIdent(c.cache, "result"), nil, n.info)) addDecl(c, newSym(skUnknown, getIdent(c.cache, "result"), nil, n.info))

View file

@ -0,0 +1,25 @@
discard """
output: '''Inh
45'''
"""
type
Base = ref object of RootObj
field: int
Inh = ref object of Base
# bug #6777
method foo(b: Base): var int {.base.} =
echo "Base"
result = b.field
method foo(b: Inh): var int =
echo "Inh"
result = b.field
var x: Base
var y = Inh(field: 45)
x = y
echo foo(x)