syntax icon indicating copy to clipboard operation
syntax copied to clipboard

\"==" unexpectedly compiles to === instead of caml_equal

Open Minnozz opened this issue 3 years ago • 1 comments

I would expect \"==" to compile to Caml_obj.caml_equal, just like == does, but instead it compiles to ===:

type eq<'t> = ('t, 't) => bool

type t
@val external x: t = "x"
@val external y: t = "y"

let comp = eq => eq(x, y)

Js.Console.log2("== normal", comp((a, b) => a == b))
Js.Console.log2("== escaped", comp(\"=="))
Js.Console.log2("=== normal", comp((a, b) => a === b))
// "The value === can't be found":
//Js.Console.log2("=== escaped", comp(\"==="))
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';

var Curry = require("./stdlib/curry.js");
var Caml_obj = require("./stdlib/caml_obj.js");

function comp(eq) {
  return Curry._2(eq, x, y);
}

console.log("== normal", Caml_obj.caml_equal(x, y));

console.log("== escaped", x === y);

console.log("=== normal", x === y);

exports.comp = comp;
/*  Not a pure module */

Playground link

Minnozz avatar Aug 10 '22 10:08 Minnozz

This might be related to #335?

johnridesabike avatar Sep 18 '22 12:09 johnridesabike

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 15:05 stale[bot]