diff --git a/CHANGELOG.md b/CHANGELOG.md index ccadb4c33c..0ac56891d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,12 @@ - Make the `--help` arg be prioritized in the CLI, so correctly prints help message and skip other commands. https://github.com/rescript-lang/rescript-compiler/pull/6667 +# 11.1.0-rc.7 + +#### :bug: Bug Fix + +- Fix variance setting for builtin `dict` type. Fixes issues around inference. https://github.com/rescript-lang/rescript-compiler/pull/6707 + # 11.1.0-rc.6 #### :rocket: New Feature diff --git a/jscomp/build_tests/super_errors/expected/dict_inference.res.expected b/jscomp/build_tests/super_errors/expected/dict_inference.res.expected new file mode 100644 index 0000000000..42f32b879e --- /dev/null +++ b/jscomp/build_tests/super_errors/expected/dict_inference.res.expected @@ -0,0 +1,13 @@ + + We've found a bug for you! + /.../fixtures/dict_inference.res:4:31-33 + + 2 │ dict->Js.Dict.set("someKey1", 1) + 3 │ dict->Js.Dict.set("someKey2", 2) + 4 │ dict->Js.Dict.set("someKey2", "2") + 5 │ + + This has type: string + But this function argument is expecting: int + + You can convert string to int with Belt.Int.fromString. \ No newline at end of file diff --git a/jscomp/build_tests/super_errors/fixtures/dict_inference.res b/jscomp/build_tests/super_errors/fixtures/dict_inference.res new file mode 100644 index 0000000000..703f0c672e --- /dev/null +++ b/jscomp/build_tests/super_errors/fixtures/dict_inference.res @@ -0,0 +1,4 @@ +let dict = Js.Dict.empty() +dict->Js.Dict.set("someKey1", 1) +dict->Js.Dict.set("someKey2", 2) +dict->Js.Dict.set("someKey2", "2") diff --git a/jscomp/ml/predef.ml b/jscomp/ml/predef.ml index f318d7e84d..fb45e343d2 100644 --- a/jscomp/ml/predef.ml +++ b/jscomp/ml/predef.ml @@ -238,7 +238,7 @@ let common_initial_env add_type add_extension empty_env = {decl_abstr with type_params = [tvar]; type_arity = 1; - type_variance = [Variance.covariant]} + type_variance = [Variance.full]} and decl_uncurried = let tvar1, tvar2 = newgenvar(), newgenvar() in {decl_abstr with diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index d21ca55b4d..317583d49c 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -25,7 +25,7 @@ o runtime/caml_exceptions.cmj : cc_cmi runtime/caml_exceptions.res | runtime/cam o runtime/caml_exceptions.cmi : cc runtime/caml_exceptions.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_float.cmj : cc_cmi runtime/caml_float.res | runtime/caml_float.cmi runtime/caml_float_extern.cmj o runtime/caml_float.cmi : cc runtime/caml_float.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml.cmj runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj +o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj o runtime/caml_format.cmi : cc runtime/caml_format.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_hash.cmj : cc_cmi runtime/caml_hash.res | runtime/caml_hash.cmi runtime/caml_hash_primitive.cmj runtime/caml_nativeint_extern.cmj runtime/js.cmj o runtime/caml_hash.cmi : cc runtime/caml_hash.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj @@ -41,7 +41,7 @@ o runtime/caml_md5.cmj : cc_cmi runtime/caml_md5.res | runtime/caml_array_extern o runtime/caml_md5.cmi : cc runtime/caml_md5.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_module.cmj : cc_cmi runtime/caml_module.res | runtime/caml_array_extern.cmj runtime/caml_module.cmi runtime/caml_obj.cmj o runtime/caml_module.cmi : cc runtime/caml_module.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.res | runtime/caml.cmj runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj +o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.res | runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj o runtime/caml_obj.cmi : cc runtime/caml_obj.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_option.cmj : cc_cmi runtime/caml_option.res | runtime/caml_option.cmi runtime/caml_undefined_extern.cmj runtime/js.cmj o runtime/caml_option.cmi : cc runtime/caml_option.resi | runtime/bs_stdlib_mini.cmi runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj @@ -58,7 +58,7 @@ o runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj : cc runtime/cam o runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj : cc runtime/caml_external_polyfill.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj : cc runtime/caml_int64_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.res | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/caml_option.cmj runtime/js.cmi runtime/js.cmj +o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.res | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/js.cmi runtime/js.cmj o runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj : cc runtime/caml_nativeint_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj : cc runtime/caml_string_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj diff --git a/jscomp/test/DictInference.js b/jscomp/test/DictInference.js new file mode 100644 index 0000000000..21819986a0 --- /dev/null +++ b/jscomp/test/DictInference.js @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Js_dict = require("../../lib/js/js_dict.js"); + +var dict = {}; + +dict["someKey1"] = 1; + +dict["someKey2"] = 2; + +var asArray = Js_dict.values(dict); + +exports.dict = dict; +exports.asArray = asArray; +/* Not a pure module */ diff --git a/jscomp/test/DictInference.res b/jscomp/test/DictInference.res new file mode 100644 index 0000000000..cabae911e5 --- /dev/null +++ b/jscomp/test/DictInference.res @@ -0,0 +1,4 @@ +let dict = Js.Dict.empty() +dict->Js.Dict.set("someKey1", 1) +dict->Js.Dict.set("someKey2", 2) +let asArray = dict->Js.Dict.values diff --git a/packages/playground-bundling/package-lock.json b/packages/playground-bundling/package-lock.json index d3a1faa332..21da087299 100644 --- a/packages/playground-bundling/package-lock.json +++ b/packages/playground-bundling/package-lock.json @@ -9,22 +9,22 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@rescript/core": "^0.6.0", - "@rescript/react": "^0.12.0" + "@rescript/core": "^1.1.0", + "@rescript/react": "^0.12.1" } }, "node_modules/@rescript/core": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@rescript/core/-/core-0.6.0.tgz", - "integrity": "sha512-D4ykxSpbmxbQa99kCg6/DztwCNt1tV3t11BLSOvJPHNLSIuQxfAU3ddgRruaH9LQSKOrMUjxQS9z6RdG5iFPoA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@rescript/core/-/core-1.1.0.tgz", + "integrity": "sha512-pz/CL8+9hBUTeMpUouvZohNsa5rqIwurlXoa1CZWN0ZKuWjMVjaoQ3V+0NB72J/QBbs6/8W82VABKBaDn3fGCA==", "peerDependencies": { - "rescript": "^10.1.0 || ^11.0.0-alpha.0 || next" + "rescript": ">=11.0.0 || ^11.1.0-rc.2" } }, "node_modules/@rescript/react": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@rescript/react/-/react-0.12.0.tgz", - "integrity": "sha512-EBLsf5rD7sJOjgfLLGwuLw/hONszc3UtYnIVgv7OdTyUNR41/m4deVm62PI0agvr3kWakXz4KchKRSd+19/bRA==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@rescript/react/-/react-0.12.1.tgz", + "integrity": "sha512-ZD7nhDr5FZgLYqRH9s4CNM+LRz/3IMuTb+LH12fd2Akk0xYkYUP+DZveB2VQUC2UohJnTf/c8yPSNsiFihVCCg==", "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" @@ -74,16 +74,18 @@ } }, "node_modules/rescript": { - "version": "10.1.4", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-10.1.4.tgz", - "integrity": "sha512-FFKlS9AG/XrLepWsyw7B+A9DtQBPWEPDPDKghV831Y2KGbie+eeFBOS0xtRHp0xbt7S0N2Dm6hhX+kTZQ/3Ybg==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.1.tgz", + "integrity": "sha512-7T4PRp/d0+CBNnY6PYKffFqo9tGZlvnZpboF/n+8SKS+JZ6VvXJO7W538VPZXf3EYx1COGAWWvkF9e/HgSAqHg==", "hasInstallScript": true, "peer": true, "bin": { "bsc": "bsc", - "bsrefmt": "bsrefmt", "bstracing": "lib/bstracing", "rescript": "rescript" + }, + "engines": { + "node": ">=10" } }, "node_modules/scheduler": { @@ -98,15 +100,15 @@ }, "dependencies": { "@rescript/core": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@rescript/core/-/core-0.6.0.tgz", - "integrity": "sha512-D4ykxSpbmxbQa99kCg6/DztwCNt1tV3t11BLSOvJPHNLSIuQxfAU3ddgRruaH9LQSKOrMUjxQS9z6RdG5iFPoA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@rescript/core/-/core-1.1.0.tgz", + "integrity": "sha512-pz/CL8+9hBUTeMpUouvZohNsa5rqIwurlXoa1CZWN0ZKuWjMVjaoQ3V+0NB72J/QBbs6/8W82VABKBaDn3fGCA==", "requires": {} }, "@rescript/react": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@rescript/react/-/react-0.12.0.tgz", - "integrity": "sha512-EBLsf5rD7sJOjgfLLGwuLw/hONszc3UtYnIVgv7OdTyUNR41/m4deVm62PI0agvr3kWakXz4KchKRSd+19/bRA==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@rescript/react/-/react-0.12.1.tgz", + "integrity": "sha512-ZD7nhDr5FZgLYqRH9s4CNM+LRz/3IMuTb+LH12fd2Akk0xYkYUP+DZveB2VQUC2UohJnTf/c8yPSNsiFihVCCg==", "requires": {} }, "js-tokens": { @@ -144,9 +146,9 @@ } }, "rescript": { - "version": "10.1.4", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-10.1.4.tgz", - "integrity": "sha512-FFKlS9AG/XrLepWsyw7B+A9DtQBPWEPDPDKghV831Y2KGbie+eeFBOS0xtRHp0xbt7S0N2Dm6hhX+kTZQ/3Ybg==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.1.tgz", + "integrity": "sha512-7T4PRp/d0+CBNnY6PYKffFqo9tGZlvnZpboF/n+8SKS+JZ6VvXJO7W538VPZXf3EYx1COGAWWvkF9e/HgSAqHg==", "peer": true }, "scheduler": { diff --git a/packages/playground-bundling/package.json b/packages/playground-bundling/package.json index c876bf1172..879dfa91f7 100644 --- a/packages/playground-bundling/package.json +++ b/packages/playground-bundling/package.json @@ -11,7 +11,7 @@ "author": "", "license": "ISC", "dependencies": { - "@rescript/core": "^0.6.0", - "@rescript/react": "^0.12.0" + "@rescript/core": "^1.1.0", + "@rescript/react": "^0.12.1" } }