mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fixes #4177
This commit is contained in:
@@ -43,9 +43,11 @@ proc rawHandleSelf(c: PContext; owner: PSym) =
|
||||
if arg.name.id == c.selfName.id:
|
||||
c.p.selfSym = arg
|
||||
arg.flags.incl sfIsSelf
|
||||
let t = c.p.selfSym.typ.skipTypes(abstractPtrs)
|
||||
if t.kind == tyObject:
|
||||
var t = c.p.selfSym.typ.skipTypes(abstractPtrs)
|
||||
while t.kind == tyObject:
|
||||
addObjFieldsToLocalScope(c, t.n)
|
||||
if t.sons[0] == nil: break
|
||||
t = t.sons[0].skipTypes(abstractPtrs)
|
||||
|
||||
proc pushProcCon*(c: PContext; owner: PSym) =
|
||||
rawPushProcCon(c, owner)
|
||||
|
||||
15
tests/usingstmt/tthis.nim
Normal file
15
tests/usingstmt/tthis.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
# bug #4177
|
||||
|
||||
type
|
||||
Parent = object of RootObj
|
||||
parentField: int
|
||||
Child = object of Parent
|
||||
childField: int
|
||||
|
||||
{.this: self.}
|
||||
proc sumFields(self: Child): int =
|
||||
result = parentField + childField # Error: undeclared identifier: 'parentField'
|
||||
|
||||
proc sumFieldsWorks(self: Child): int =
|
||||
result = self.parentField + childField
|
||||
Reference in New Issue
Block a user