parent
8bb1a6b041
commit
e68adca0c9
2 changed files with 26 additions and 2 deletions
|
|
@ -1883,14 +1883,13 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
|||
|
||||
c.p.wasForwarded = proto != nil
|
||||
maybeAddResult(c, s, n)
|
||||
if s.kind == skMethod: semMethodPrototype(c, s, n)
|
||||
|
||||
if lfDynamicLib notin s.loc.flags:
|
||||
# no semantic checking for importc:
|
||||
s.ast[bodyPos] = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||
# unfortunately we cannot skip this step when in 'system.compiles'
|
||||
# context as it may even be evaluated in 'system.compiles':
|
||||
trackProc(c, s, s.ast[bodyPos])
|
||||
if s.kind == skMethod: semMethodPrototype(c, s, n)
|
||||
else:
|
||||
if (s.typ.sons[0] != nil and kind != skIterator) or kind == skMacro:
|
||||
addDecl(c, newSym(skUnknown, getIdent(c.cache, "result"), nil, n.info))
|
||||
|
|
|
|||
25
tests/method/treturn_var_t.nim
Normal file
25
tests/method/treturn_var_t.nim
Normal 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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue