mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-23 19:36:53 +00:00
Merge pull request #2643 from grncdr/TAny-and-inheritance
Resolve base type fields in `[](TAny, string)`
This commit is contained in:
@@ -340,6 +340,8 @@ proc `[]`*(x: Any, fieldName: string): Any =
|
||||
if n != nil:
|
||||
result.value = x.value +!! n.offset
|
||||
result.rawType = n.typ
|
||||
elif x.rawType.kind == tyObject and x.rawType.base != nil:
|
||||
return `[]`(TAny(value: x.value, rawType: x.rawType.base), fieldName)
|
||||
else:
|
||||
raise newException(ValueError, "invalid field name: " & fieldName)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user