Compiler: Closure iterators: Handle comma in multi-exception except variant#25922
Conversation
| # `nkStmtList` means we hit a comma in a `FirstException, SecondException` expression. | ||
| # We skip it and go to the next child, which must be a `nkType` representing the next expection. | ||
| if c[i].kind == nkStmtList: | ||
| continue |
There was a problem hiding this comment.
Makes no sense. The structure is supposed to be except-guard-A, except-guard-B, ..., [last] nkStmtList
There was a problem hiding this comment.
Sorry, this really is a silly take 😕 Somehow I thought that RangeDefect, Exception is traversed as nkType, nkStmtList, nkType, which is wrong, of course. I should have slept at this time of night probably instead of making blind guesses and spending CI cycles and your time.
In the PNode the nkExceptBranch that represents except RangeDefect, Exception looks like this:
except RangeDefect,
... :tmpSlLower0 = Exception:
... complete(retFutParamSym_603979901, result)
... return nil
I.e. Exception is not represented as nkType at all, while it is a type. Maybe the problem is with PNode construction that happens earlier.
The structure is supposed to be except-guard-A, except-guard-B, ..., [last] nkStmtList
Yeah, matching each exception type individually works, no problem here. The problem is I can't match multiple exceptions in one except branch.
AFAIK matching multiple exception types is allowed and valid in except branches, so this should work.
|
Fixed in devel. |
Closes #25921