robotframework-lsp icon indicating copy to clipboard operation
robotframework-lsp copied to clipboard

Undefined variable error appears when trying to access a global variable defined in a separate file

Open ryanrosello-og opened this issue 3 years ago • 2 comments

This may be related to ...

https://github.com/robocorp/robotframework-lsp/issues/641

The red squiggly line appears when trying to access a global variable defined in a separate file:

2023-01-25_13-21-13

Create a robot file test_a.robot with the following content:

*** Test Cases ***
    Set Global Variable    ${thisISGlobal}    globar var test

Attempt to refer to the global variable from another robot file test_b.robot

*** Test Cases ***
    Log    ${thisISGlobal}

Python version: 3.10 vscode: 1.74.3 Robot Framework Language Server: 1.8.0

ryanrosello-og avatar Jan 25 '23 03:01 ryanrosello-og

I see this same thing. I import a variables file but it does not take it into account.

VAR_FROM_VARIABLES_FILE is defined in ../variables.py which it correctly sees as a valid import.

image

red8888 avatar Mar 13 '23 17:03 red8888

@red8888 % variables are loaded as environment variables, not global variables (so, in your example it should really fail).

fabioz avatar Mar 13 '23 18:03 fabioz