Skip to content

Commit

Permalink
fix tcustom_numeric_literals test
Browse files Browse the repository at this point in the history
The field part of a dot expression may now be a symbol choice, which
interferes with rendering of custom numeric literals (e.g., `1'lit`),
where the special rendering was only enabled for `nkIdent` and `nkSym`
nodes.

To keep the test working, `getPIdent` (which is used by `isCustomLit`)
now also returns the identifier for symbol-choice nodes.
  • Loading branch information
zerbina committed May 3, 2024
1 parent 2276e2b commit 137c8a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/ast/ast_query.nim
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ const
## not be performed for arguments to these magics.

proc getPIdent*(a: PNode): PIdent {.inline.} =
## Returns underlying `PIdent` for `{nkSym, nkIdent}`, or `nil`.
# xxx consider whether also returning the 1st ident for {nkOpenSymChoice, nkClosedSymChoice}
# which may simplify code.
## Returns underlying `PIdent` for `{nkSym, nkIdent, nkOpenSymChoice,
## nkClosedSymChoice}`, or `nil`.
case a.kind
of nkSym: a.sym.name
of nkIdent: a.ident
of nkSymChoices: a[0].sym.name
else: nil

proc getIdentLineInfo*(n: PNode): TLineInfo =
Expand Down

0 comments on commit 137c8a7

Please sign in to comment.