diff --git a/CHANGELOG.md b/CHANGELOG.md index 9068f87a5e..3d0ef88301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Fix accidental removal of `Belt.Result.Ok` and `Belt.Result.Error` constructors in rc.5 https://github.com/rescript-lang/rescript-compiler/pull/6514 - Add missing check that the runtime representation of variants matches implementation and interface. https://github.com/rescript-lang/rescript-compiler/pull/6513/files - GenType: only export types (not values) from module types. https://github.com/rescript-lang/rescript-compiler/pull/6516 +- Fix compiler crash with unboxed variant definition with only 1 constructor. https://github.com/rescript-lang/rescript-compiler/pull/6523 # 11.0.0-rc.7 diff --git a/jscomp/ml/typedecl.ml b/jscomp/ml/typedecl.ml index 344cdd2462..43a8b3f05f 100644 --- a/jscomp/ml/typedecl.ml +++ b/jscomp/ml/typedecl.ml @@ -337,6 +337,8 @@ let transl_declaration ~typeRecordAsObject env sdecl id = end; let unboxed_status = match sdecl.ptype_kind with + | Ptype_variant [{pcd_args = Pcstr_tuple []; _}] -> + unboxed_false_default_false | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable = Immutable; _}]; _}] diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index 0ee038afc0..39735c74f6 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -583,6 +583,10 @@ var Aliased = { test: test }; +var OnlyOne = { + onlyOne: "OnlyOne" +}; + var i = 42; var i2 = 42.5; @@ -629,4 +633,5 @@ exports.PromiseSync = PromiseSync; exports.Arr = Arr; exports.AllInstanceofTypes = AllInstanceofTypes; exports.Aliased = Aliased; +exports.OnlyOne = OnlyOne; /* l2 Not a pure module */ diff --git a/jscomp/test/UntaggedVariants.res b/jscomp/test/UntaggedVariants.res index 65ec308172..0bcfe81208 100644 --- a/jscomp/test/UntaggedVariants.res +++ b/jscomp/test/UntaggedVariants.res @@ -427,3 +427,8 @@ module Aliased = { } } } + +module OnlyOne = { + @unboxed type onlyOne = OnlyOne + let onlyOne = OnlyOne +} \ No newline at end of file