Skip to content

RM-37765: Fix FP for document-constants for type aliases#116

Merged
reniers-tiobe merged 2 commits intomainfrom
37765-fix-fp-document-constants
Jan 23, 2026
Merged

RM-37765: Fix FP for document-constants for type aliases#116
reniers-tiobe merged 2 commits intomainfrom
37765-fix-fp-document-constants

Conversation

@reniers-tiobe
Copy link
Contributor

Fixed false positive on const declaration for a generic type, such as const AnyTree = Union{SyntaxNode, GreenNode}

We do this by checking whether right-hand side of assignment node is of kind curly, which seem to denote generic (parameterized) types. We do still generate violations on expressions such Vector{Float64}(undef, 3), which are calls.

reniers-tiobe and others added 2 commits January 23, 2026 14:15
Fixed false positive on `const` declaration for a generic type, such as `const AnyTree = Union{SyntaxNode, GreenNode}`

We do this by checking whether right-hand side of assignment node is of kind `curly`, which seem to denote generic (parameterized) types. We do still generate violations on expressions such `Vector{Float64}(undef, 3)`, which are `call`s.
Copy link
Contributor

@brouwers-tiobe brouwers-tiobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in my comment, the rule still reports a FP on global const MYCONST.

However, this is not a regression and global const is discouraged by no-global-keyword-in-global-scope.

So LGTM!

else
@debug "An assignment without children:" assignment

if kind(const_node.parent) == K"doc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the doc node is not necessarily the direct parent; for example I'm getting a FP on the following:

"doc"
global const n = 1

as global would be in between const and doc:

[toplevel]
  [doc]
    [string]
      "doc"                              :: String
    [global]
      [const]
        [=]
          n                              :: Identifier
          1                              :: Integer

However, I'm not sure when this construction would reasonably be used (it violates no-global-keyword-in-global-scope as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

@reniers-tiobe reniers-tiobe merged commit c810701 into main Jan 23, 2026
2 of 3 checks passed
@reniers-tiobe reniers-tiobe deleted the 37765-fix-fp-document-constants branch January 23, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants