Skip to content

R UI parameter insertion can reuse script-level loop variables #9313

Closed

Description

@carloea2

What happened?

Adding an integer UI parameter named count to an R script with an existing for (count in 1:3) loop generates count <- UiParameter(...)$value before the loop. The loop then overwrites the parameter's supplied value: a panel value of 42 becomes 3.

The insertion code checks assignment targets but misses the iterator introduced by for. Expected: choose an unused variable such as count_2, leaving the loop's count separate from the UI parameter.

Reproduced with the actual frontend insertion function and the companion R SDK on R 4.5.3. Introduced by #9279.

How to reproduce?

  1. Use an R UDF script containing:

    for (count in 1:3) NULL
    function(table, port) table
  2. Add an integer UI parameter named count, with value 42.

  3. Inspect the generated declaration. It reuses count instead of choosing an unused variable.

  4. Evaluate the generated declaration followed by the loop using the R SDK. The generated parameter variable contains 3, although its supplied value was 42.

Version/Branch

1.4.0-incubating-SNAPSHOT (main)

Commit Hash (Optional)

a786d47

What browsers are you seeing the problem on?

No response

Relevant log output

Generated identifier: count
Parameter: 3 Loop: 3
Error: result$parameter == 42L is not TRUE
Execution halted

Activity

  1. carloea2 commented on Nov 4, 2026

    @carloea2
    ContributorAuthor

    /take

  2. added theissue type on Nov 4, 2026
  3. added a commit that references this issue on Nov 10, 2026
    4e14404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions