Skip to content

Unnecessary variables generated for string literals as partial function args #5489

Closed
@cknitt

Description

@cknitt

This is a regression in current master that is similar to the already solved #5454.

Consider the following ReScript code:

let concat = (a, b, c) => a ++ b ++ c

let result = ["a", "b"]->Js.Array2.map(concat("c", "d"))

In ReScript 9, this compiles to:

function concat(a, b, c) {
  return a + b + c;
}

var result = [
    "a",
    "b"
  ].map(function (param) {
      return concat("c", "d", param);
    });

In current master, this compiles to

function concat(a, b, c) {
  return a + b + c;
}

var partial_arg = "d";

var partial_arg$1 = "c";

var result = [
    "a",
    "b"
  ].map(function (param) {
      return concat(partial_arg$1, partial_arg, param);
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions