Skip to content

Unnecessary variables generated for string literals in record fields #5454

Closed
@cknitt

Description

@cknitt

This is item 5 from my list of observations in #5418 (changes in compiler output from 9.1.4 to current master).

On current master,

type t = {
  a: string,
  b: string,
  c: Belt.Set.String.t,
}

let empty = {
  a: "A",
  b: "B",
  c: Belt.Set.String.empty,
}

compiles to

var empty_a = "A";

var empty_b = "B";

var empty = {
  a: empty_a,
  b: empty_b,
  c: undefined
};

whereas in 9.1.4, I get

var empty = {
  a: "A",
  b: "B",
  c: undefined
};

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