Skip to content

Generated function argument names conflict with inlined JS #452

Description

@bbugh

The generated function arguments m, n, o can conflict with the actual JS values (particularly n which is not uncommon as a variable name), causing weird errors.

Given a module:

module Example {
  fun show(something : a, list: b, value: c) {
    `
    (() => {
      for (let n = 0; n < #{list}.length; n++) {
        console.log(#{list}[n])
      }
    })()
    `
  }
}

This generates:

const AH = new(class extends _M {
  b(n, m, o) {
    return ((() => {
          for (let n = 0; n < m.length; n++) {
            console.log(m[n])
          }
        })());
  }
});

The n defined in the JavaScript code is shadowing the n defined as the minified argument name.

It seems like these generated arguments should be ones that cannot conflict, perhaps with an index/uuid like n9208, or __0__, __1__, etc..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions