RM-37765: Fix FP for document-constants for type aliases#116
Merged
reniers-tiobe merged 2 commits intomainfrom Jan 23, 2026
Merged
RM-37765: Fix FP for document-constants for type aliases#116reniers-tiobe merged 2 commits intomainfrom
document-constants for type aliases#116reniers-tiobe merged 2 commits intomainfrom
Conversation
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.
brouwers-tiobe
approved these changes
Jan 23, 2026
Contributor
brouwers-tiobe
left a comment
There was a problem hiding this comment.
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" |
Contributor
There was a problem hiding this comment.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed false positive on
constdeclaration for a generic type, such asconst 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 suchVector{Float64}(undef, 3), which arecalls.