New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser does not find hidden EnumerationMember references #3238
Comments
Indeed, using an enum member in an expression, results in the member being identified as a runtime expression, or unrecognized. There's also a resolver bug with naming conflicts, and it's impossible to rename an enum member and retain the leading underscore (I'll raise separate issues): Public Enum FoodType
Apple = 4
Orange = 5
Plum = 3
End Enum
Public Enum FruitType
[_First] = 1
Apple = 1
Orange = 2
Plum = [FoodType].[Plum] 'These are identified as Enum and Enum member
Applorange = Apple Or Orange 'VBA's resolved value is 3, but in RD, Apple is recognized as FoodType.Apple, and Orange as FoodType.Orange
[_Last] = 3
[_Count1] = [_Last] - [_First] + 1 '[_Last] and [_First] expression variables are identified as "runtime expression"
[_Count2] = [FruitType].[_Last] - FruitType.[_First] + 1 '[FruitType] and FruitType are correctly identified, [_Last] and [_First] are unrecognized tokens
End Enum |
@ThunderFrame unrecognized tokens, as in unresolved? |
yep - as in RD toolbar doesn't know what to make of them. |
This is a problem with with how We should be consistent between the backing dictionary and the function. I would propose to remove the brackets as well when building the dictionary since enclosing a reference in brackets is a legal way to reference the same declaration. As an additional consideration, do we want to include the brackets in the identifier in the first place? Technically, they are not part of the name and only present to make an otherwise illegal name legal. Moreover, having them in there will probably cause wrong references in examples as the one below: Private Enum FruitTypes
Apple
[[Apple]]
[Orange]
[_Strawberry]
[[_Strawberry]]
End Enum
Private Sub Test()
Debug.Print FruitTypes.Apple 'Prints 0
Debug.Print FruitTypes.[Apple] 'Prints 0
Debug.Print FruitTypes.[[Apple]] 'Prints 1
Debug.Print FruitTypes.Orange 'Prints 2
Debug.Print FruitTypes.[Orange] 'Prints 2
Debug.Print FruitTypes.[_Strawberry] 'Prints 3
Debug.Print FruitTypes.[[_Strawberry]] 'Prints 4
End Sub Note that IntelliSense and auto-completing are confused here as well. So, considering this, I would suggest to leave the mismatch in removing the brackets between the backing dictionary and |
FWIW, I did some experiments based on the Based on your above comments, I would expect the following assumptions and logic to be true:
I did some experiments using a modified version of the Also, the 'success' of applying the above logic to single bracketed expressions (which required some use of identifier validation code) made me wonder if there was enough 'mutual dependency' to justify making name validation part of the |
First, I think changing the declaration finder is the wrong approach here. The problem is that we do not follow the VBA logic of ignoring the outermost enclosing brackets at the declaration. If you look at what IntelliSense shows, you will only see the versions with one less pair of brackets. Regarding putting name validation on the |
When the declaration of EnumerationMember
[_Last]
is selected (e.g., to rename), the usage/reference inMsgBox CStr(FruitType.[_Last])
is not discovered/listed as a reference.The text was updated successfully, but these errors were encountered: