robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
168 stars 13 forks source link

[ENHANCEMENT]: Nested variables returned from FOR loops are not recognized #217

Closed zastress closed 4 months ago

zastress commented 4 months ago

Is your enhancement request related to a problem? Please describe. Variables that return from a FOR loop are not recognized further if the initial declaration was nested

Example

FOR    ${INDEX}    IN RANGE    0    3
        VAR    ${brand-name${INDEX}}    somevalue    scope=TEST 
END
@{brands-list}    Create List    ${brand-name0}    ${brand-name1}    ${brand-name2}

2024-02-13_12-18-23

Noordsestern commented 4 months ago

Hi,

thank you for reporting the issue.

The incident has nothing to do with the FOR loop. The variable is only determined during runtime, thus it is impossible to predict the variable name statically. The code must be executed in order to know the variable name.

Given that the usecase for this feature is likely and edge case and the correctness of the variable name would have to be "guessed" (and thus predicted wrong), effort would not justify the means and risks.

Regards

d-biehl commented 4 months ago

If you write something like this, and you know that it is correct code for Robot, but RobotCode says there is an error, you can tell RobotCode that it should ignore this error by adding a comment at the end of the line # robotcode: ignore There is also a QuickFix for this, set the cursor to the variable name and click the yellow light bulb.

d-biehl commented 4 months ago
image
zastress commented 4 months ago

Thank you for the response, Daniel. I just added #robotcode: ignore. I don't need to create a new variable because that is actually declared inside the FOR loop.