Skip to content
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

2.2.0 warnings from Redim ... As #4107

Closed
SystemsModelling opened this issue Jun 18, 2018 · 4 comments
Closed

2.2.0 warnings from Redim ... As #4107

SystemsModelling opened this issue Jun 18, 2018 · 4 comments
Labels
bug Identifies work items for known bugs duplicate Thanks for the feedback! We're already tracking this report/request at the linked issue. feature-inspections inspection-false-positive A bug where an inspection result appears, even though it is incorrect. resolver Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.

Comments

@SystemsModelling
Copy link

ReDim Result(StringLen) As String

gets me several warnings:
Variable 'Result' is used but not assigned
Local variable 'Result' is not declared.

This gives no warnings:

Dim Result() As String
ReDim Result(StringLen)
@Vogel612 Vogel612 added bug Identifies work items for known bugs feature-inspections inspection-false-positive A bug where an inspection result appears, even though it is incorrect. resolver Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees. labels Jun 18, 2018
@Vogel612
Copy link
Member

Could you add the extended version information from the logs, please? Thank You :)

@SystemsModelling
Copy link
Author

RubberduckLog.txt

Code:

  Option Explicit
  
  Sub testReDim()
  Const length As Long = 2
  ReDim Result(length) As String
  End Sub
  
  Sub testDimReDim()
  Const length As Long = 2
  Dim Result() As String
  ReDim Result(length)
  End Sub

@retailcoder
Copy link
Member

That's a tough one. The resolver currently isn't treating ReDim statements as declarations, because it literally can't know whether the identifier is or isn't Dim'd elsewhere (e.g. a global array declared in another module) in scope.

VBA ReDim statements are dual-purposed: they serve as executable declaration statements, and as a statement that resizes a dynamic array.

Rubberduck can't treat them as executable declaration statements, so "variable 'Results' is not declared" isn't entirely wrong, but it's not per language specs either. So yes, it's a bug, but I don't see how we can fix it without introducing an entire parse pass dedicated to finding what array identifiers are available in global scope - which isn't impossible, but feels overkill, when adding an explicit Dim statement removes it.

"Variable not assigned" inspection needs to ignore arrays though.

@ChrisBrackett
Copy link

This might be a duplicate of #2522.

@retailcoder retailcoder added the duplicate Thanks for the feedback! We're already tracking this report/request at the linked issue. label May 12, 2019
Semi-automatic bug tracker automation moved this from ToDo to Done May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs duplicate Thanks for the feedback! We're already tracking this report/request at the linked issue. feature-inspections inspection-false-positive A bug where an inspection result appears, even though it is incorrect. resolver Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.
Projects
Development

No branches or pull requests

4 participants