Skip to content

Some operators generating duplicate exports in es6 and commonjs #3807

@andywhite37

Description

@andywhite37

With Bucklescript 5.0.6, the following (ReasonML) code:

let (<&>) = (a, b) => a + b;
let (<?>) = (a, b) => a + b;

produces this .bs.js output:

// Generated by BUCKLESCRIPT VERSION 5.0.6, PLEASE EDIT WITH CARE


function $less$unknown$great(a, b) {
  return a + b | 0;
}

function $less$unknown$great$1(a, b) {
  return a + b | 0;
}

export {
  $less$unknown$great ,
  $less$unknown$great$1 as $less$unknown$great,
  
}
/* No side effect */

There seem to be two issues here:

  1. & and ? don't seem to be recognized as valid characters in the operators, and are represented as $unknown in the js
  2. in the export list, the $less$unknown$great name is being duplicated, which causes problems in webpack, etc.

If these characters are invalid, I would think the compiler would reject them rather than using $unknown. If $less$unknown$great$1 was not aliased as $less$unknown$great in the export list, that would also fix the problem of duplicate exports.

My current workaround is to use a different character in the operator, which does not result in the $unknown (e.g. ^ => $caret).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions