File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -243,24 +243,25 @@ so if wantting the attr inherited from SupCls, just write it as-is (e.g. `self.a
243
243
if obj.kind != nnkIdent:
244
244
# class O([SupCls])
245
245
if obj.kind == nnkCall:
246
- let first = obj[1 ]
247
- case first.kind
248
- of nnkBracketExpr:
249
- parseGenerics first
250
- of nnkIdent, nnkObjectTy:
251
- # class O(...)
252
- classId = obj[0 ]
246
+ if obj[0 ].kind == nnkBracketExpr:
247
+ parseGenerics obj[0 ]
253
248
else :
254
- error " metaclass/object.__init_subclass__ is not implemented yet, " &
255
- " only one positional param is allowed for class, got " &
256
- $ obj.kind, first
249
+ let arg = obj[1 ]
250
+ case arg.kind
251
+ of nnkIdent, nnkObjectTy, nnkDotExpr, nnkBracketExpr:
252
+ # class O(...)
253
+ classId = obj[0 ]
254
+ else :
255
+ error " metaclass/object.__init_subclass__ is not implemented yet, " &
256
+ " only one positional param is allowed for class, got " &
257
+ $ obj.kind & " whose 1st node kind is " & $ arg.kind, arg
257
258
let supLen = obj.len - 1
258
259
if supLen > 1 :
259
260
error " multi-inhert is not allowed in Nim, " &
260
261
" i.e. only one super class is expected, got " & $ supLen
261
262
elif supLen == 1 :
262
263
# class O(SupCls)
263
- supCls = first
264
+ supCls = obj[ 1 ]
264
265
if supCls.kind != nnkObjectTy: # not `class O(object)`
265
266
supClsNode = nnkOfInherit.newTree supCls
266
267
defPragmas.remove1 ident" base"
You can’t perform that action at this time.
0 commit comments