Skip to content

Commit

Permalink
Fix Obj.magic, Obj.repr etc. appearing in JS output
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Oct 5, 2024
1 parent 2be44d5 commit 39f5505
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 194 deletions.
5 changes: 2 additions & 3 deletions lib/es6/js_exn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import * as Primitive_option from "./primitive_option.js";
let $$Error = "JsError";

function asJsExn(exn) {
let t = exn;
if (t.RE_EXN_ID === $$Error) {
return Primitive_option.some(t._1);
if (exn.RE_EXN_ID === $$Error) {
return Primitive_option.some(exn._1);
}

}
Expand Down
52 changes: 1 addition & 51 deletions lib/es6/obj.js
Original file line number Diff line number Diff line change
@@ -1,51 +1 @@



function magic(prim) {
return prim;
}

function repr(prim) {
return prim;
}

function obj(prim) {
return prim;
}

function tag(prim) {
return prim.TAG;
}

function size(prim) {
return prim.length | 0;
}

function field(prim0, prim1) {
return prim0[prim1];
}

function set_field(prim0, prim1, prim2) {
prim0[prim1] = prim2;
}

function dup(prim) {
return {...prim};
}

function update_dummy(prim0, prim1) {
Object.assign(prim0, prim1);
}

export {
magic,
repr,
obj,
tag,
size,
field,
set_field,
dup,
update_dummy,
}
/* No side effect */
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
5 changes: 2 additions & 3 deletions lib/js/js_exn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ let Primitive_option = require("./primitive_option.js");
let $$Error = "JsError";

function asJsExn(exn) {
let t = exn;
if (t.RE_EXN_ID === $$Error) {
return Primitive_option.some(t._1);
if (exn.RE_EXN_ID === $$Error) {
return Primitive_option.some(exn._1);
}

}
Expand Down
50 changes: 1 addition & 49 deletions lib/js/obj.js
Original file line number Diff line number Diff line change
@@ -1,49 +1 @@
'use strict';


function magic(prim) {
return prim;
}

function repr(prim) {
return prim;
}

function obj(prim) {
return prim;
}

function tag(prim) {
return prim.TAG;
}

function size(prim) {
return prim.length | 0;
}

function field(prim0, prim1) {
return prim0[prim1];
}

function set_field(prim0, prim1, prim2) {
prim0[prim1] = prim2;
}

function dup(prim) {
return {...prim};
}

function update_dummy(prim0, prim1) {
Object.assign(prim0, prim1);
}

exports.magic = magic;
exports.repr = repr;
exports.obj = obj;
exports.tag = tag;
exports.size = size;
exports.field = field;
exports.set_field = set_field;
exports.dup = dup;
exports.update_dummy = update_dummy;
/* No side effect */
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
20 changes: 10 additions & 10 deletions runtime/obj.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@

type t = Primitive_object_extern.t

let magic = Primitive_object_extern.magic
external magic: 'a => 'b = "%identity"

@deprecated("Do not use directly. This will be removed in v13")
let repr = Primitive_object_extern.repr
external repr: 'a => t = "%identity"

@deprecated("Do not use directly. This will be removed in v13")
let obj = Primitive_object_extern.obj
external obj: t => 'a = "%identity"

@deprecated("Do not use directly. This will be removed in v13")
let tag = Primitive_object_extern.tag
external tag: t => int = "%obj_tag"

@deprecated("Do not use directly. This will be removed in v13")
let size = Primitive_object_extern.size
external size: t => int = "%obj_size"

@deprecated("Do not use directly. This will be removed in v13")
let field = Primitive_object_extern.getField
external getField: (t, 'a) => t = "%obj_get_field"

@deprecated("Do not use directly. This will be removed in v13")
let set_field = Primitive_object_extern.setField
external setField: (t, 'a, t) => unit = "%obj_set_field"

@deprecated("Do not use directly. This will be removed in v13")
let dup = Primitive_object_extern.dup
external dup: t => t = "%obj_dup"

@deprecated("Do not use directly. This will be removed in v13")
let update_dummy = Primitive_object_extern.updateDummy
@deprecated("Do not use directly. This will be removed in v13") @scope("Object")
external updateDummy: (t, t) => unit = "assign"
3 changes: 1 addition & 2 deletions tests/tests/src/UntaggedVariants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions tests/tests/src/exception_raise_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions tests/tests/src/gpr_1946_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/tests/src/gpr_4069_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions tests/tests/src/int_poly_var.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 39f5505

Please sign in to comment.