Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Extended variable assignment doesn't work with @ or & syntax #5405

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

Closed
ericli-splunk opened this issue Apr 18, 2025 · 1 comment
Closed

Extended variable assignment doesn't work with @ or & syntax #5405

ericli-splunk opened this issue Apr 18, 2025 · 1 comment

Comments

@ericli-splunk
Copy link

Version info

  • Robot Framework 7.2.2 (Python 3.11.11 on darwin)
  • OS: macOS 15.3.2

Steps to reproduce

  1. Run the following robot test, (e.g. robot a.robot)
    *** Test Cases ***
    Test
        ${a}=    Create List    v1    v2
        @{b}=    Create List    w1    w2
        &{c}=    Create Dictionary
        ${c.d}=    Set Variable    x
        ${c.e}=    Create List    y1    y2
        @{c.f}=    Create List    z1    z2
        Log    a=${{repr($a)}}    WARN
        Log    b=${{repr($b)}}    WARN
        Log    c=${{repr($c)}}    WARN
    
  2. See the following warning messages
    a=['v1', 'v2']
    b=['w1', 'w2']
    c={'d': 'x', 'e': ['y1', 'y2']}
    

Expected behavior: see

a=['v1', 'v2']
b=['w1', 'w2']
c={'d': 'x', 'e': ['y1', 'y2'], 'f': ['z1', 'z2']}

Explanation: According to Create List's documentation, its result can be assigned to either ${scalar} or @{list} variables. It also works well when assigning to ${c.e} (c is a dictionary). However, it does not work when assigning to @{c.f}. Also, there are no error messages about the failed assignment.

@pekkaklarck
Copy link
Member

It seems that "extended assignment" using ${var.attr} syntax (#1059) works only when using the $ syntax, not with @ or & syntax. When you use it like @{c.f}, a variable with base name c.f is created instead of attribute f being added to c. The original issue doesn't mention @ and & syntax at all, so I believe they just weren't taken into account.

Interestingly the newer "item assignment" syntax supports @ and & just fine. For example, this works as expected:

@{c}[f]=    Create List    z1    z2

Luckily fixing the @{c.f} syntax isn't hard.

@pekkaklarck pekkaklarck added this to the v7.3 milestone May 7, 2025
@pekkaklarck pekkaklarck self-assigned this May 7, 2025
@pekkaklarck pekkaklarck changed the title Unable to create dictionary keys using "@{...}" Extended variable assignment doesn't work with @ or & syntax May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants