robocorp / robotframework-lsp

Robocorp extensions for VS Code: Robocorp Code and RFW LSP
https://robocorp.com/docs/developer-tools/visual-studio-code
Apache License 2.0
201 stars 91 forks source link

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

Open ryanrosello-og opened 1 year ago

ryanrosello-og commented 1 year ago

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

red8888 commented 1 year ago

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
fabioz commented 1 year ago

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