diff --git a/changes/forbid-proto-field-name.breaking.md b/changes/forbid-proto-field-name.breaking.md new file mode 100644 index 0000000000..1a51374a90 --- /dev/null +++ b/changes/forbid-proto-field-name.breaking.md @@ -0,0 +1 @@ +- A record field, object field or `@tag` can no longer have the JavaScript name `__proto__`, which sets an object's prototype instead of a property. diff --git a/compiler/backend/js_exp_make.ml b/compiler/backend/js_exp_make.ml index 5e734c9d54..58a204834a 100644 --- a/compiler/backend/js_exp_make.ml +++ b/compiler/backend/js_exp_make.ml @@ -761,21 +761,6 @@ let obj ?dup properties : t = let obj_entries entries : t = {expression_desc = Object entries; comment = None; source_loc = None} -let define_own_property (e : t) (name : string) (value : t) : t = - call ~info:Js_call_info.ml_full_call - (dot (js_global "Object") "defineProperty") - [ - e; - str name; - obj - [ - (Js_op.Lit "value", value); - (Js_op.Lit "writable", true_); - (Js_op.Lit "enumerable", true_); - (Js_op.Lit "configurable", true_); - ]; - ] - let rec triple_equal ?comment (e0 : t) (e1 : t) : t = match (e0.expression_desc, e1.expression_desc) with | ( (Null | Undefined _), diff --git a/compiler/backend/js_exp_make.mli b/compiler/backend/js_exp_make.mli index e0c891f6dd..19cc450ef2 100644 --- a/compiler/backend/js_exp_make.mli +++ b/compiler/backend/js_exp_make.mli @@ -282,11 +282,6 @@ val obj : ?dup:J.expression -> J.property_map -> t val obj_entries : J.object_entry list -> t -val define_own_property : t -> string -> t -> t -(** [Object.defineProperty(e, name, {value, ...})]: defines [name] as an own - data property of [e], as a property of an object literal does, where an - assignment would run a setter that [e] inherits *) - val true_ : t val false_ : t diff --git a/compiler/backend/lam_compile.ml b/compiler/backend/lam_compile.ml index 6fe20f7a1d..0f61772afa 100644 --- a/compiler/backend/lam_compile.ml +++ b/compiler/backend/lam_compile.ml @@ -2239,24 +2239,15 @@ let compile output_prefix = the statements of every override have run, so they could mutate the base before the copy. Copy first, then set each field. *) let copy = E.var id in - (* Each override is an own property of the copy, as it is of the - literal. Assigning a field makes one, except for [__proto__] - when [init] has no own [__proto__]: the assignment runs the - setter the copy inherits from [Object.prototype], which sets - the prototype of the copy, or does nothing. *) - let set_field fld_info i value = - match set_field_name fld_info with - | "__proto__" -> E.define_own_property copy "__proto__" value - | _ -> - Js_of_lam_block.set_field fld_info copy (Int32.of_int i) value - in let assignments = List.concat_map (fun (i, fld_info, set_loc, (output : Js_output.t), value) -> output.block @ [ S.exp - (with_source_loc set_loc (set_field fld_info i value)); + (with_source_loc set_loc + (Js_of_lam_block.set_field fld_info copy + (Int32.of_int i) value)); ]) overrides in diff --git a/compiler/typing/ast_untagged_variants.ml b/compiler/typing/ast_untagged_variants.ml index 8942a35632..a7ddceed3d 100644 --- a/compiler/typing/ast_untagged_variants.ml +++ b/compiler/typing/ast_untagged_variants.ml @@ -36,6 +36,7 @@ type error = | InvalidVariantTagAnnotation | InvalidUntaggedVariantDefinition of untagged_error | TagFieldNameConflict of string * string * string + | ProtoFieldName | UnboxedOnConstructor of {constructor: string; single_field_record: bool} | InvalidInstanceOf | InvalidModuleClass of string @@ -109,6 +110,11 @@ let report_error ppf = value of inline record field \"%s\". Use a different @tag name or \ rename the field." constructor_name runtime_value field_name + | ProtoFieldName -> + fprintf ppf + "A field's JavaScript name can't be __proto__: in JavaScript, it sets \ + the object's prototype instead of a property. Use another name, or a \ + dict." | UnboxedOnConstructor {constructor; single_field_record} -> fprintf ppf "@@unboxed applies to a whole variant: write it on the type, as in \ @@ -562,6 +568,12 @@ let check_runtime_annotation ~loc ~is_abstract_or_abbreviation ClassLocationWithoutClass (txt, missing) ))) attrs +(* [__proto__] is an accessor that every object inherits from + [Object.prototype], so a field or tag with that runtime name can't be read + or written like other properties. *) +let check_runtime_field_name ~loc name = + if name = "__proto__" then raise (Error (loc, ProtoFieldName)) + let process_tag_name (attrs : Parsetree.attributes) = let st = ref None in List.iter @@ -571,7 +583,9 @@ let process_tag_name (attrs : Parsetree.attributes) = if !st = None then ( (match Ast_payload.semantic_string_of_payload payload with | None -> () - | Some s -> st := Some s); + | Some s -> + check_runtime_field_name ~loc s; + st := Some s); if !st = None then raise (Error (loc, InvalidVariantTagAnnotation))) else raise (Error (loc, Duplicated_bs_as)) | _ -> ()) diff --git a/compiler/typing/typedecl.ml b/compiler/typing/typedecl.ml index ef13c7a69b..7352f7822b 100644 --- a/compiler/typing/typedecl.ml +++ b/compiler/typing/typedecl.ml @@ -190,6 +190,12 @@ let transl_labels ?record_name env closed lbls = (Ast_untagged_variants.Error (loc, Ast_untagged_variants.Duplicated_bs_as)) | None -> ()); + (match runtime_name with + | Some {txt; loc} -> + Ast_untagged_variants.check_runtime_field_name ~loc + (String_literal.string_semantic txt) + | None -> + Ast_untagged_variants.check_runtime_field_name ~loc:name.loc name.txt); Builtin_attributes.warning_scope attrs (fun () -> let arg = Ast_helper.Typ.force_poly arg in let cty = transl_simple_type env closed arg in diff --git a/compiler/typing/typetexp.ml b/compiler/typing/typetexp.ml index dccf9c3f1a..4a5f68aa63 100644 --- a/compiler/typing/typetexp.ml +++ b/compiler/typing/typetexp.ml @@ -617,6 +617,7 @@ and transl_fields env policy o fields = in let add_field = function | Otag (s, a, ty1) -> + Ast_untagged_variants.check_runtime_field_name ~loc:s.loc s.txt; let ty1 = Builtin_attributes.warning_scope a (fun () -> transl_poly_type env policy ty1) diff --git a/tests/compiler_tests/src/record_spread_order_test.mjs b/tests/compiler_tests/src/record_spread_order_test.mjs index 05b020378d..f8946a4891 100644 --- a/tests/compiler_tests/src/record_spread_order_test.mjs +++ b/tests/compiler_tests/src/record_spread_order_test.mjs @@ -2,7 +2,6 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; function id(x) { @@ -230,54 +229,8 @@ function simpleOverride(base) { }; } -function protoOverride(base, value) { - let newrecord = {...base}; - let tmp; - try { - tmp = id(value); - } catch (exn) { - tmp = value; - } - Object.defineProperty(newrecord, "__proto__", { - value: Primitive_option.some(tmp), - writable: true, - enumerable: true, - configurable: true - }); - return newrecord; -} - -function protoAssignedAfter(base) { - let newrecord = {...base}; - Object.defineProperty(newrecord, "__proto__", { - value: 5, - writable: true, - enumerable: true, - configurable: true - }); - Object.defineProperty(newrecord, "__proto__", { - value: 5, - writable: true, - enumerable: true, - configurable: true - }); - return newrecord; -} - -function protoUsedAfter(base) { - let newrecord = {...base}; - Object.defineProperty(newrecord, "__proto__", { - value: 5, - writable: true, - enumerable: true, - configurable: true - }); - id(newrecord.name); - return newrecord; -} - Mocha.describe("Record_spread_order_test", () => { - Mocha.test("an override that mutates the base", () => Test_utils.eq("File \"record_spread_order_test.res\", line 236, characters 7-14", mutateInOverride({ + Mocha.test("an override that mutates the base", () => Test_utils.eq("File \"record_spread_order_test.res\", line 209, characters 7-14", mutateInOverride({ a: 1, b: 2 }).a, 1)); @@ -287,7 +240,7 @@ Mocha.describe("Record_spread_order_test", () => { a: 1, b: 2 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 242, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 215, characters 7-14", order, [ "base", "b" ]); @@ -298,12 +251,12 @@ Mocha.describe("Record_spread_order_test", () => { a: 1, b: 2 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 248, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 221, characters 7-14", order, [ "base2", "a2", "b2" ]); - Test_utils.eq("File \"record_spread_order_test.res\", line 249, characters 7-14", [ + Test_utils.eq("File \"record_spread_order_test.res\", line 222, characters 7-14", [ res.a, res.b ], [ @@ -317,7 +270,7 @@ Mocha.describe("Record_spread_order_test", () => { b: 2 }; let res = simpleOverride(base); - Test_utils.eq("File \"record_spread_order_test.res\", line 255, characters 7-14", [ + Test_utils.eq("File \"record_spread_order_test.res\", line 228, characters 7-14", [ res.a, res.b, base.b @@ -333,11 +286,11 @@ Mocha.describe("Record_spread_order_test", () => { a: 0, b: 0 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 261, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 234, characters 7-14", order, [ "a", "b" ]); - Test_utils.eq("File \"record_spread_order_test.res\", line 262, characters 7-14", [ + Test_utils.eq("File \"record_spread_order_test.res\", line 235, characters 7-14", [ res.a, res.b ], [ @@ -349,11 +302,11 @@ Mocha.describe("Record_spread_order_test", () => { a: 0, b: 0 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 265, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 238, characters 7-14", order, [ "a", "b" ]); - Test_utils.eq("File \"record_spread_order_test.res\", line 266, characters 7-14", [ + Test_utils.eq("File \"record_spread_order_test.res\", line 239, characters 7-14", [ res$1.a, res$1.b ], [ @@ -363,7 +316,7 @@ Mocha.describe("Record_spread_order_test", () => { }); Mocha.test("fields assigned after the spread", () => { clearOrder(); - Test_utils.eq("File \"record_spread_order_test.res\", line 271, characters 7-14", assignAfter({ + Test_utils.eq("File \"record_spread_order_test.res\", line 244, characters 7-14", assignAfter({ x: 0, y: 0 }), { @@ -371,12 +324,12 @@ Mocha.describe("Record_spread_order_test", () => { y: 1, z: 1 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 272, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 245, characters 7-14", order, [ "first", "second" ]); clearOrder(); - Test_utils.eq("File \"record_spread_order_test.res\", line 274, characters 7-14", assignAfterExpression({ + Test_utils.eq("File \"record_spread_order_test.res\", line 247, characters 7-14", assignAfterExpression({ x: 0, y: 0 }), { @@ -384,20 +337,20 @@ Mocha.describe("Record_spread_order_test", () => { y: 1, z: 1 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 275, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 248, characters 7-14", order, [ "first", "second" ]); }); Mocha.test("a field assigned a value that reads the copy", () => { - Test_utils.eq("File \"record_spread_order_test.res\", line 279, characters 7-14", readCopy({ + Test_utils.eq("File \"record_spread_order_test.res\", line 252, characters 7-14", readCopy({ x: 0, y: 0 }), { x: 1, y: 2 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 280, characters 7-14", readCopyInSwitch({ + Test_utils.eq("File \"record_spread_order_test.res\", line 253, characters 7-14", readCopyInSwitch({ x: 1, y: 2 }), { @@ -406,11 +359,11 @@ Mocha.describe("Record_spread_order_test", () => { }); }); Mocha.test("the last assignment of a field wins", () => { - Test_utils.eq("File \"record_spread_order_test.res\", line 284, characters 7-14", assignTwice({ + Test_utils.eq("File \"record_spread_order_test.res\", line 257, characters 7-14", assignTwice({ x: 0, y: 0 }).x, 2); - Test_utils.eq("File \"record_spread_order_test.res\", line 285, characters 7-14", assignTwiceTry({ + Test_utils.eq("File \"record_spread_order_test.res\", line 258, characters 7-14", assignTwiceTry({ x: 0, y: 0 }).x, 4); @@ -420,21 +373,21 @@ Mocha.describe("Record_spread_order_test", () => { a: 1, b: 2 }; - Test_utils.eq("File \"record_spread_order_test.res\", line 290, characters 7-14", pureStatements(base, { + Test_utils.eq("File \"record_spread_order_test.res\", line 263, characters 7-14", pureStatements(base, { a: 3, b: 4 }), { a: 1, b: 8 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 291, characters 7-14", pureStatementsAfterCall(base, { + Test_utils.eq("File \"record_spread_order_test.res\", line 264, characters 7-14", pureStatementsAfterCall(base, { a: 3, b: 4 }), { a: 1, b: 200 }); - Test_utils.eq("File \"record_spread_order_test.res\", line 292, characters 7-14", callThenPureStatements(base, { + Test_utils.eq("File \"record_spread_order_test.res\", line 265, characters 7-14", callThenPureStatements(base, { a: 3, b: 4 }), { @@ -444,24 +397,24 @@ Mocha.describe("Record_spread_order_test", () => { }); Mocha.test("a discarded result", () => { clearOrder(); - Test_utils.eq("File \"record_spread_order_test.res\", line 297, characters 7-14", discarded({ + Test_utils.eq("File \"record_spread_order_test.res\", line 270, characters 7-14", discarded({ a: 1, b: 2 }), 1); - Test_utils.eq("File \"record_spread_order_test.res\", line 298, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 271, characters 7-14", order, [ "a", "b" ]); }); Mocha.test("an override that throws", () => { clearOrder(); - Test_utils.throws("File \"record_spread_order_test.res\", line 303, characters 11-18", () => { + Test_utils.throws("File \"record_spread_order_test.res\", line 276, characters 11-18", () => { throwing({ a: 1, b: 2 }); }); - Test_utils.eq("File \"record_spread_order_test.res\", line 304, characters 7-14", order, [ + Test_utils.eq("File \"record_spread_order_test.res\", line 277, characters 7-14", order, [ "base", "a" ]); @@ -473,10 +426,10 @@ Mocha.describe("Record_spread_order_test", () => { b: 2 }); if (typeof match !== "object") { - return Test_utils.ok("File \"record_spread_order_test.res\", line 310, characters 18-25", false); + return Test_utils.ok("File \"record_spread_order_test.res\", line 283, characters 18-25", false); } let a = match.a; - Test_utils.eq("File \"record_spread_order_test.res\", line 309, characters 27-34", [ + Test_utils.eq("File \"record_spread_order_test.res\", line 282, characters 27-34", [ a, match.b ], [ @@ -484,40 +437,6 @@ Mocha.describe("Record_spread_order_test", () => { 5 ]); }); - Mocha.test("an override of a field named __proto__ is an own property", () => { - let withInt = protoOverride({ - name: "int" - }, 5); - Test_utils.ok("File \"record_spread_order_test.res\", line 316, characters 7-14", Object.hasOwn(withInt, "__proto__")); - Test_utils.eq("File \"record_spread_order_test.res\", line 317, characters 7-14", withInt.__proto__, 5); - let withObject = protoOverride({ - name: "object" - }, { - z: 1 - }); - Test_utils.ok("File \"record_spread_order_test.res\", line 319, characters 7-14", Object.hasOwn(withObject, "__proto__")); - Test_utils.eq("File \"record_spread_order_test.res\", line 320, characters 7-14", withObject.__proto__, { - z: 1 - }); - Test_utils.ok("File \"record_spread_order_test.res\", line 321, characters 7-14", Object.getPrototypeOf(withObject) === Object.prototype); - let overridden = protoOverride({ - name: "own", - ["__proto__"]: 1 - }, 2); - Test_utils.eq("File \"record_spread_order_test.res\", line 323, characters 7-14", overridden.__proto__, 2); - }); - Mocha.test("a __proto__ field set on the copy is an own property", () => { - let assigned = protoAssignedAfter({ - name: "assigned" - }); - Test_utils.ok("File \"record_spread_order_test.res\", line 328, characters 7-14", Object.hasOwn(assigned, "__proto__")); - Test_utils.eq("File \"record_spread_order_test.res\", line 329, characters 7-14", assigned.__proto__, 5); - let used = protoUsedAfter({ - name: "used" - }); - Test_utils.ok("File \"record_spread_order_test.res\", line 331, characters 7-14", Object.hasOwn(used, "__proto__")); - Test_utils.eq("File \"record_spread_order_test.res\", line 332, characters 7-14", used.__proto__, 5); - }); Mocha.test("an exception's record", () => { let match = exceptionRecord({ RE_EXN_ID: Extension, @@ -526,10 +445,10 @@ Mocha.describe("Record_spread_order_test", () => { c: undefined }); if (match.RE_EXN_ID !== Extension) { - return Test_utils.ok("File \"record_spread_order_test.res\", line 338, characters 14-21", false); + return Test_utils.ok("File \"record_spread_order_test.res\", line 290, characters 14-21", false); } let a = match.a; - Test_utils.eq("File \"record_spread_order_test.res\", line 337, characters 30-37", [ + Test_utils.eq("File \"record_spread_order_test.res\", line 289, characters 30-37", [ a, match.b ], [ @@ -564,8 +483,5 @@ export { exceptionRecord, clearOrder, simpleOverride, - protoOverride, - protoAssignedAfter, - protoUsedAfter, } /* Not a pure module */ diff --git a/tests/compiler_tests/src/record_spread_order_test.res b/tests/compiler_tests/src/record_spread_order_test.res index ec05631a17..cddf4e7ad8 100644 --- a/tests/compiler_tests/src/record_spread_order_test.res +++ b/tests/compiler_tests/src/record_spread_order_test.res @@ -204,33 +204,6 @@ let clearOrder = () => order->Array.splice(~start=0, ~remove=Array.length(order) let simpleOverride = (base: r) => {...base, b: id(9)} -@val external hasOwn: ('a, string) => bool = "Object.hasOwn" -@val external getPrototypeOf: 'a => 'b = "Object.getPrototypeOf" -@val external objectPrototype: 'a = "Object.prototype" - -type proto<'a> = {name: string, @as("__proto__") proto?: 'a} - -let protoOverride = (base: proto<'a>, value: 'a) => { - ...base, - proto: try id(value) catch { - | _ => value - }, -} - -type mutableProto = {name: string, @as("__proto__") mutable mutableProto?: int} - -let protoAssignedAfter = (base: mutableProto) => { - let x = {...base, mutableProto: 5} - x.mutableProto = Some(5) - x -} - -let protoUsedAfter = (base: mutableProto) => { - let x = {...base, mutableProto: 5} - ignore(id(x.name)) - x -} - describe(__MODULE__, () => { test("an override that mutates the base", () => { eq(__LOC__, mutateInOverride({a: 1, b: 2}).a, 1) @@ -311,27 +284,6 @@ describe(__MODULE__, () => { } ) - test("an override of a field named __proto__ is an own property", () => { - let withInt = protoOverride({name: "int"}, 5) - ok(__LOC__, hasOwn(withInt, "__proto__")) - eq(__LOC__, withInt.proto, Some(5)) - let withObject = protoOverride({name: "object"}, {"z": 1}) - ok(__LOC__, hasOwn(withObject, "__proto__")) - eq(__LOC__, withObject.proto, Some({"z": 1})) - ok(__LOC__, getPrototypeOf(withObject) === objectPrototype) - let overridden = protoOverride({name: "own", proto: 1}, 2) - eq(__LOC__, overridden.proto, Some(2)) - }) - - test("a __proto__ field set on the copy is an own property", () => { - let assigned = protoAssignedAfter({name: "assigned"}) - ok(__LOC__, hasOwn(assigned, "__proto__")) - eq(__LOC__, assigned.mutableProto, Some(5)) - let used = protoUsedAfter({name: "used"}) - ok(__LOC__, hasOwn(used, "__proto__")) - eq(__LOC__, used.mutableProto, Some(5)) - }) - test("an exception's record", () => switch exceptionRecord(Extension({a: 1, b: 2})) { | Extension({a, b}) => eq(__LOC__, (a, b), (1, 5)) diff --git a/tests/error_tests/single/expected/proto_field_name.res.expected b/tests/error_tests/single/expected/proto_field_name.res.expected new file mode 100644 index 0000000000..9c86bba826 --- /dev/null +++ b/tests/error_tests/single/expected/proto_field_name.res.expected @@ -0,0 +1,8 @@ + + We've found a bug for you! + /.../fixtures/proto_field_name.res:1:25-33 + + 1 │ type t = {name: string, __proto__: int} + 2 │ + + A field's JavaScript name can't be __proto__: in JavaScript, it sets the object's prototype instead of a property. Use another name, or a dict. \ No newline at end of file diff --git a/tests/error_tests/single/expected/proto_field_name_as.res.expected b/tests/error_tests/single/expected/proto_field_name_as.res.expected new file mode 100644 index 0000000000..54708669be --- /dev/null +++ b/tests/error_tests/single/expected/proto_field_name_as.res.expected @@ -0,0 +1,8 @@ + + We've found a bug for you! + /.../fixtures/proto_field_name_as.res:1:25-27 + + 1 │ type t = {name: string, @as("__proto__") parent?: int} + 2 │ + + A field's JavaScript name can't be __proto__: in JavaScript, it sets the object's prototype instead of a property. Use another name, or a dict. \ No newline at end of file diff --git a/tests/error_tests/single/expected/proto_object_field_name.res.expected b/tests/error_tests/single/expected/proto_object_field_name.res.expected new file mode 100644 index 0000000000..1feabcb229 --- /dev/null +++ b/tests/error_tests/single/expected/proto_object_field_name.res.expected @@ -0,0 +1,8 @@ + + We've found a bug for you! + /.../fixtures/proto_object_field_name.res:1:27-37 + + 1 │ type t = {"name": string, "__proto__": int} + 2 │ + + A field's JavaScript name can't be __proto__: in JavaScript, it sets the object's prototype instead of a property. Use another name, or a dict. \ No newline at end of file diff --git a/tests/error_tests/single/expected/proto_variant_tag.res.expected b/tests/error_tests/single/expected/proto_variant_tag.res.expected new file mode 100644 index 0000000000..ca665bc7ad --- /dev/null +++ b/tests/error_tests/single/expected/proto_variant_tag.res.expected @@ -0,0 +1,9 @@ + + We've found a bug for you! + /.../fixtures/proto_variant_tag.res:1:1-4 + + 1 │ @tag("__proto__") + 2 │ type t = A({x: int}) | B({y: int}) + 3 │ + + A field's JavaScript name can't be __proto__: in JavaScript, it sets the object's prototype instead of a property. Use another name, or a dict. \ No newline at end of file diff --git a/tests/error_tests/single/fixtures/proto_field_name.res b/tests/error_tests/single/fixtures/proto_field_name.res new file mode 100644 index 0000000000..bc3c655582 --- /dev/null +++ b/tests/error_tests/single/fixtures/proto_field_name.res @@ -0,0 +1 @@ +type t = {name: string, __proto__: int} diff --git a/tests/error_tests/single/fixtures/proto_field_name_as.res b/tests/error_tests/single/fixtures/proto_field_name_as.res new file mode 100644 index 0000000000..3c1fb57ed0 --- /dev/null +++ b/tests/error_tests/single/fixtures/proto_field_name_as.res @@ -0,0 +1 @@ +type t = {name: string, @as("__proto__") parent?: int} diff --git a/tests/error_tests/single/fixtures/proto_object_field_name.res b/tests/error_tests/single/fixtures/proto_object_field_name.res new file mode 100644 index 0000000000..598bae9dc1 --- /dev/null +++ b/tests/error_tests/single/fixtures/proto_object_field_name.res @@ -0,0 +1 @@ +type t = {"name": string, "__proto__": int} diff --git a/tests/error_tests/single/fixtures/proto_variant_tag.res b/tests/error_tests/single/fixtures/proto_variant_tag.res new file mode 100644 index 0000000000..f1e53e2a2b --- /dev/null +++ b/tests/error_tests/single/fixtures/proto_variant_tag.res @@ -0,0 +1,2 @@ +@tag("__proto__") +type t = A({x: int}) | B({y: int})