Skip to content

Label name not checked and incorrect code emitted for label in external definition #7323

Closed
@cknitt

Description

@cknitt

This:

@send external reduce: (array<'b>, ('a, 'b) => 'a, ~initialValue: 'a=?) => 'a = "reduce"
let reduce = (arr, initialValue, f) => reduce(arr, f, ~initialValue)

compiles fine:

function reduce(arr, initialValue, f) {
  return arr.reduce(f, initialValue);
}

However, when I change the label name:

@send external reduce: (array<'b>, ('a, 'b) => 'a, ~wrongLabelName: 'a=?) => 'a = "reduce"
let reduce = (arr, initialValue, f) => reduce(arr, f, ~initialValue)
  1. the code compiles (which it shouldn't, because the label name does not match)
  2. I get the following incorrect output (v12):
function reduce(arr, initialValue, f) {
  return arr.reduce(f)(initialValue);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions