diff --git a/package-lock.json b/package-lock.json index 19d91c0bb..91f48b642 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "ghreleases": "^3.0.2", "mocha": "^10.7.3", "nodemon": "^3.1.4", - "rollup": "^4.21.0", + "rollup": "^4.22.4", "terser": "^5.31.6", "typescript": "^5.5.4" }, @@ -118,208 +118,192 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.0.tgz", - "integrity": "sha512-WTWD8PfoSAJ+qL87lE7votj3syLavxunWhzCnx3XFxFiI/BA/r3X7MUM8dVrH8rb2r4AiO8jJsr3ZjdaftmnfA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], - "license": "MIT", "optional": true, "os": [ "android" ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.0.tgz", - "integrity": "sha512-a1sR2zSK1B4eYkiZu17ZUZhmUQcKjk2/j9Me2IDjk1GHW7LB5Z35LEzj9iJch6gtUfsnvZs1ZNyDW2oZSThrkA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], - "license": "MIT", "optional": true, "os": [ "android" ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.0.tgz", - "integrity": "sha512-zOnKWLgDld/svhKO5PD9ozmL6roy5OQ5T4ThvdYZLpiOhEGY+dp2NwUmxK0Ld91LrbjrvtNAE0ERBwjqhZTRAA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], - "license": "MIT", "optional": true, "os": [ "darwin" ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.0.tgz", - "integrity": "sha512-7doS8br0xAkg48SKE2QNtMSFPFUlRdw9+votl27MvT46vo44ATBmdZdGysOevNELmZlfd+NEa0UYOA8f01WSrg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], - "license": "MIT", "optional": true, "os": [ "darwin" ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.0.tgz", - "integrity": "sha512-pWJsfQjNWNGsoCq53KjMtwdJDmh/6NubwQcz52aEwLEuvx08bzcy6tOUuawAOncPnxz/3siRtd8hiQ32G1y8VA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", "cpu": [ "arm" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.0.tgz", - "integrity": "sha512-efRIANsz3UHZrnZXuEvxS9LoCOWMGD1rweciD6uJQIx2myN3a8Im1FafZBzh7zk1RJ6oKcR16dU3UPldaKd83w==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "cpu": [ "arm" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.0.tgz", - "integrity": "sha512-ZrPhydkTVhyeGTW94WJ8pnl1uroqVHM3j3hjdquwAcWnmivjAwOYjTEAuEDeJvGX7xv3Z9GAvrBkEzCgHq9U1w==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.0.tgz", - "integrity": "sha512-cfaupqd+UEFeURmqNP2eEvXqgbSox/LHOyN9/d2pSdV8xTrjdg3NgOFJCtc1vQ/jEke1qD0IejbBfxleBPHnPw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.0.tgz", - "integrity": "sha512-ZKPan1/RvAhrUylwBXC9t7B2hXdpb/ufeu22pG2psV7RN8roOfGurEghw1ySmX/CmDDHNTDDjY3lo9hRlgtaHg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", "cpu": [ "ppc64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.0.tgz", - "integrity": "sha512-H1eRaCwd5E8eS8leiS+o/NqMdljkcb1d6r2h4fKSsCXQilLKArq6WS7XBLDu80Yz+nMqHVFDquwcVrQmGr28rg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", "cpu": [ "riscv64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.0.tgz", - "integrity": "sha512-zJ4hA+3b5tu8u7L58CCSI0A9N1vkfwPhWd/puGXwtZlsB5bTkwDNW/+JCU84+3QYmKpLi+XvHdmrlwUwDA6kqw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", "cpu": [ "s390x" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.0.tgz", - "integrity": "sha512-e2hrvElFIh6kW/UNBQK/kzqMNY5mO+67YtEh9OA65RM5IJXYTWiXjX6fjIiPaqOkBthYF1EqgiZ6OXKcQsM0hg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.0.tgz", - "integrity": "sha512-1vvmgDdUSebVGXWX2lIcgRebqfQSff0hMEkLJyakQ9JQUbLDkEaMsPTLOmyccyC6IJ/l3FZuJbmrBw/u0A0uCQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.0.tgz", - "integrity": "sha512-s5oFkZ/hFcrlAyBTONFY1TWndfyre1wOMwU+6KCpm/iatybvrRgmZVM+vCFwxmC5ZhdlgfE0N4XorsDpi7/4XQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], - "license": "MIT", "optional": true, "os": [ "win32" ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.0.tgz", - "integrity": "sha512-G9+TEqRnAA6nbpqyUqgTiopmnfgnMkR3kMukFBDsiyy23LZvUCpiUwjTRx6ezYCjJODXrh52rBR9oXvm+Fp5wg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], - "license": "MIT", "optional": true, "os": [ "win32" ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.0.tgz", - "integrity": "sha512-2jsCDZwtQvRhejHLfZ1JY6w6kEuEtfF9nzYsZxzSlNVKDX+DpsDJ+Rbjkm74nvg2rdx0gwBS+IMdvwJuq3S9pQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], - "license": "MIT", "optional": true, "os": [ "win32" @@ -1800,10 +1784,9 @@ } }, "node_modules/rollup": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.21.0.tgz", - "integrity": "sha512-vo+S/lfA2lMS7rZ2Qoubi6I5hwZwzXeUIctILZLbHI+laNtvhhOIon2S1JksA5UEDQ7l3vberd0fxK44lTYjbQ==", - "license": "MIT", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dependencies": { "@types/estree": "1.0.5" }, @@ -1815,22 +1798,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.21.0", - "@rollup/rollup-android-arm64": "4.21.0", - "@rollup/rollup-darwin-arm64": "4.21.0", - "@rollup/rollup-darwin-x64": "4.21.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.21.0", - "@rollup/rollup-linux-arm-musleabihf": "4.21.0", - "@rollup/rollup-linux-arm64-gnu": "4.21.0", - "@rollup/rollup-linux-arm64-musl": "4.21.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.21.0", - "@rollup/rollup-linux-riscv64-gnu": "4.21.0", - "@rollup/rollup-linux-s390x-gnu": "4.21.0", - "@rollup/rollup-linux-x64-gnu": "4.21.0", - "@rollup/rollup-linux-x64-musl": "4.21.0", - "@rollup/rollup-win32-arm64-msvc": "4.21.0", - "@rollup/rollup-win32-ia32-msvc": "4.21.0", - "@rollup/rollup-win32-x64-msvc": "4.21.0", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } }, diff --git a/package.json b/package.json index 445ac5738..d2644feb0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "ghreleases": "^3.0.2", "mocha": "^10.7.3", "nodemon": "^3.1.4", - "rollup": "^4.21.0", + "rollup": "^4.22.4", "terser": "^5.31.6", "typescript": "^5.5.4" }, diff --git a/src/Fable.Cli/CHANGELOG.md b/src/Fable.Cli/CHANGELOG.md index a3ab53261..b74b1ab63 100644 --- a/src/Fable.Cli/CHANGELOG.md +++ b/src/Fable.Cli/CHANGELOG.md @@ -7,14 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 4.22.0 - 2024-10-02 + +### Added + +* [Rust] Added support for Dictionary/HashSet comparers (by @ncave) +* [Rust] Updated support for interface object expressions (by @ncave) +* [Rust] Added missing ResizeArray methods and tests (by @ncave) +* [Rust] Added Async.Sleep and test (by @ncave) + +### Fixed + +* [GH-3900](https://github.com/fable-compiler/Fable/pull/3900) [Python] Fix nuget packages with hypens in their names (by @MangelMaxime) +* [Rust] Uncurry field types for object expressions (by @ncave) +* [Rust] Fixed pattern matching on `this` argument (by @ncave) +* [All] Fixed Missing DU member with interface (#3915) (by @ncave) +* [TS] Fixed missing Async type signature (#3864) (by @MangelMaxime) + ## 4.21.0 - 2024-09-19 ### Added * [JS/TS] Add support for `OrdinalIgnoreCase` overload for `String.EndsWith` (#3892) (by @goswinr) * [JS/TS] Add `uri.Port`, `uri.IsDefaultPort` (by @MangelMaxime) -* [Rust] Added support for Dictionary/HashSet comparers (by @ncave) -* [Rust] Updated support for interface object expressions (by @ncave) ### Changed diff --git a/src/Fable.Cli/Fable.Cli.fsproj b/src/Fable.Cli/Fable.Cli.fsproj index 3751e5eb2..7000172ad 100644 --- a/src/Fable.Cli/Fable.Cli.fsproj +++ b/src/Fable.Cli/Fable.Cli.fsproj @@ -4,22 +4,21 @@ true Exe net9.0 - 4.21.0 + 4.22.0 ## Added -- [JS/TS] Add support for `OrdinalIgnoreCase` overload for `String.EndsWith` (#3892) (by @goswinr) -- [JS/TS] Add `uri.Port`, `uri.IsDefaultPort` (by @MangelMaxime) - -## Changed - -- [Python] Remove `$` sign when reporting an error from `assert_equal` and `assert_not_equal` (#3878) (by @joprice) -- [All] Don't hide original error when failing to scan an assembly for plugin (#3896) (by @MangelMaxime) +- [Rust] Added support for Dictionary/HashSet comparers (by @ncave) +- [Rust] Updated support for interface object expressions (by @ncave) +- [Rust] Added missing ResizeArray methods and tests (by @ncave) +- [Rust] Added Async.Sleep and test (by @ncave) ## Fixed -- [JS/TS] Fix escaping of `{` and `}` in FormattableString (#3890) (by @roboz0r) -- [JS/TS] Fix `uri.Host` to return the host name without the port (by @MangelMaxime) -- [JS/TS] Fix TypeScript compilation by resolving type of `jsOptions` (#3894) (by @ManngelMaxime) +- [GH-3900](https://github.com/fable-compiler/Fable/pull/3900) [Python] Fix nuget packages with hypens in their names (by @MangelMaxime) +- [Rust] Uncurry field types for object expressions (by @ncave) +- [Rust] Fixed pattern matching on `this` argument (by @ncave) +- [All] Fixed Missing DU member with interface (#3915) (by @ncave) +- [TS] Fixed missing Async type signature (#3864) (by @MangelMaxime) diff --git a/src/Fable.Compiler/CHANGELOG.md b/src/Fable.Compiler/CHANGELOG.md index faf330449..697377ca4 100644 --- a/src/Fable.Compiler/CHANGELOG.md +++ b/src/Fable.Compiler/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 4.0.0-alpha-014 - 2024-10-02 + +### Changed + +* Fable 4.22.0 + ## 4.0.0-alpha-013 - 2024-09-19 ### Changed diff --git a/src/Fable.Compiler/Fable.Compiler.fsproj b/src/Fable.Compiler/Fable.Compiler.fsproj index 0372fa65e..211628bc9 100644 --- a/src/Fable.Compiler/Fable.Compiler.fsproj +++ b/src/Fable.Compiler/Fable.Compiler.fsproj @@ -6,10 +6,10 @@ true true Fable.Compiler - 4.0.0-alpha-013 + 4.0.0-alpha-014 ## Changed -- [All] Don't hide original error when failing to scan an assembly for plugin (#3896) (by @MangelMaxime) +- Fable 4.22.0 embedded diff --git a/src/Fable.Compiler/ProjectCracker.fs b/src/Fable.Compiler/ProjectCracker.fs index 73a419bd8..988da4ebd 100644 --- a/src/Fable.Compiler/ProjectCracker.fs +++ b/src/Fable.Compiler/ProjectCracker.fs @@ -732,7 +732,7 @@ let copyFableLibraryAndPackageSourcesPy (opts: CrackerOptions) (pkgs: FablePacka | _ -> let name = Naming.applyCaseRule Core.CaseRules.SnakeCase pkg.Id - IO.Path.Combine(opts.FableModulesDir, name.Replace(".", "_")) + IO.Path.Combine(opts.FableModulesDir, name.Replace(".", "_").Replace("-", "_")) copyDirIfDoesNotExist false sourceDir targetDir diff --git a/src/Fable.Transforms/FSharp2Fable.Util.fs b/src/Fable.Transforms/FSharp2Fable.Util.fs index 11fbe4840..6c4ad9db6 100644 --- a/src/Fable.Transforms/FSharp2Fable.Util.fs +++ b/src/Fable.Transforms/FSharp2Fable.Util.fs @@ -1075,8 +1075,13 @@ module Patterns = let (|UnionCaseTesterFor|_|) (memb: FSharpMemberOrFunctionOrValue) = match memb.DeclaringEntity with | Some ent when ent.IsFSharpUnion -> - // if memb.IsUnionCaseTester then // TODO: this currently fails, use when fixed - if memb.IsPropertyGetterMethod && memb.LogicalName.StartsWith("get_Is") then + // if memb.IsUnionCaseTester then // insufficient, could be an interface member + if + memb.IsPropertyGetterMethod + && not memb.IsDispatchSlot + && not memb.IsOverrideOrExplicitInterfaceImplementation + && memb.LogicalName.StartsWith("get_Is") + then let unionCaseName = memb.LogicalName |> Naming.replacePrefix "get_Is" "" ent.UnionCases |> Seq.tryFind (fun uc -> uc.Name = unionCaseName) else @@ -1645,6 +1650,7 @@ module TypeHelpers = (com: IFableCompiler) (ent: FSharpEntity) (compiledName: string) + (isInstance: bool) (argTypes: Fable.Type[] option) = let entRef = FsEnt.Ref ent @@ -1653,7 +1659,7 @@ module TypeHelpers = |> Option.bind (fun ent -> match ent with | :? FsEnt as entity -> - entity.TryFindMember(compiledName, isInstance = true, ?argTypes = argTypes, requireDispatchSlot = true) + entity.TryFindMember(compiledName, isInstance, ?argTypes = argTypes, requireDispatchSlot = true) | _ -> None ) @@ -2799,7 +2805,8 @@ module Util = entity |> tryFindBaseEntity (fun ent -> - tryFindAbstractMember com ent memb.CompiledName paramTypes |> Option.isSome + tryFindAbstractMember com ent memb.CompiledName memb.IsInstanceMember paramTypes + |> Option.isSome ) |> Option.defaultValue entity | _ -> entity diff --git a/src/Fable.Transforms/FSharp2Fable.fs b/src/Fable.Transforms/FSharp2Fable.fs index 7455937e8..419be7a2a 100644 --- a/src/Fable.Transforms/FSharp2Fable.fs +++ b/src/Fable.Transforms/FSharp2Fable.fs @@ -322,6 +322,7 @@ let private getImplementedSignatureInfo nonMangledNameConflicts (implementingEntity: FSharpEntity option) (sign: FSharpAbstractSignature) + isInstance = let implementingEntityFields = HashSet<_>() @@ -347,7 +348,7 @@ let private getImplementedSignatureInfo else None - tryFindAbstractMember com ent sign.Name paramTypes + tryFindAbstractMember com ent sign.Name isInstance paramTypes |> Option.map (fun m -> ent, m) ) |> Option.map (fun (ent, memb) -> @@ -424,7 +425,7 @@ let private transformObjExpr let r = makeRangeFrom over.Body let info = - getImplementedSignatureInfo com ctx r nonMangledNameConflicts None signature + getImplementedSignatureInfo com ctx r nonMangledNameConflicts None signature true let ctx, args = bindMemberArgs com ctx over.CurriedParameterGroups let! body = transformExpr com ctx [] over.Body @@ -1832,6 +1833,7 @@ let private transformImplementedSignature com.NonMangledAttachedMemberConflicts (Some implementingEntity) signature + memb.IsInstanceMember com.AddAttachedMember( entFullName, diff --git a/src/Fable.Transforms/Fable2Babel.fs b/src/Fable.Transforms/Fable2Babel.fs index eb3743c2c..c0d9bbf1e 100644 --- a/src/Fable.Transforms/Fable2Babel.fs +++ b/src/Fable.Transforms/Fable2Babel.fs @@ -757,7 +757,9 @@ module Annotation = // Move this to Replacements.tryEntity? let tryNativeOrFableLibraryInterface com ctx genArgs (ent: Fable.Entity) = match ent.FullName with + | Types.fsharpAsyncGeneric -> makeFableLibImportTypeAnnotation com ctx genArgs "AsyncBuilder" "Async" |> Some | _ when not ent.IsInterface -> None + // everything below is an interface | Types.icollection -> makeNativeTypeAnnotation com ctx genArgs "Iterable" |> Some // -> makeFableLibImportTypeAnnotation com ctx [Fable.Any] "Util" "ICollection" | Types.icollectionGeneric -> makeNativeTypeAnnotation com ctx genArgs "Iterable" |> Some diff --git a/src/Fable.Transforms/Global/Compiler.fs b/src/Fable.Transforms/Global/Compiler.fs index d5f2dda65..ec7024c67 100644 --- a/src/Fable.Transforms/Global/Compiler.fs +++ b/src/Fable.Transforms/Global/Compiler.fs @@ -2,10 +2,10 @@ namespace Fable module Literals = [] - let VERSION = "4.21.0" + let VERSION = "4.22.0" [] - let JS_LIBRARY_VERSION = "1.5.0" + let JS_LIBRARY_VERSION = "1.6.0" type CompilerOptionsHelper = static member Make diff --git a/src/Fable.Transforms/Rust/AST/Rust.AST.Helpers.fs b/src/Fable.Transforms/Rust/AST/Rust.AST.Helpers.fs index 9fbe85af1..bd8d6137c 100644 --- a/src/Fable.Transforms/Rust/AST/Rust.AST.Helpers.fs +++ b/src/Fable.Transforms/Rust/AST/Rust.AST.Helpers.fs @@ -383,18 +383,20 @@ module Paths = tokens = None } - let mkGenericPath (names: Symbol seq) (genArgs: GenericArgs option) : Path = + let mkGenericOffsetPath (names: Symbol seq) (genArgs: GenericArgs option) (offset: int) : Path = let len = Seq.length names let idents = mkPathIdents names let args i = - if i < len - 1 then - None - else + if i = len - 1 - offset then genArgs + else + None idents |> Seq.mapi (fun i ident -> mkPathSegment ident (args i)) |> mkPath + let mkGenericPath (names: Symbol seq) (genArgs: GenericArgs option) : Path = mkGenericOffsetPath names genArgs 0 + [] module Patterns = diff --git a/src/Fable.Transforms/Rust/Fable2Rust.fs b/src/Fable.Transforms/Rust/Fable2Rust.fs index 2c6b52ef9..daab8dad4 100644 --- a/src/Fable.Transforms/Rust/Fable2Rust.fs +++ b/src/Fable.Transforms/Rust/Fable2Rust.fs @@ -304,6 +304,12 @@ module TypeInfo = let parts = splitNameParts fullName mkGenericPath parts genArgsOpt + let makeStaticCallPathExpr importName membName genArgsOpt = + let fullName = importName + "::" + membName + let parts = splitNameParts fullName + let offset = 1 // genArgs position offset is one before last + mkGenericOffsetPath parts genArgsOpt offset |> mkPathExpr + let makeFullNamePathExpr fullName genArgsOpt = makeFullNamePath fullName genArgsOpt |> mkPathExpr @@ -665,12 +671,12 @@ module TypeInfo = // for constructors or static members, import just the type let selector, membName = Fable.Naming.splitLastBy "." info.Selector let importName = com.GetImportName(ctx, selector, info.Path, r) - makeFullNamePathExpr (importName + "::" + membName) genArgsOpt + makeStaticCallPathExpr importName membName genArgsOpt | Fable.LibraryImport mi when not (mi.IsInstanceMember) && not (mi.IsModuleMember) -> // for static (non-module and non-instance) members, import just the type let selector, membName = Fable.Naming.splitLastBy "::" info.Selector let importName = com.GetImportName(ctx, selector, info.Path, r) - makeFullNamePathExpr (importName + "::" + membName) genArgsOpt + makeStaticCallPathExpr importName membName genArgsOpt | _ -> // all other imports let importName = com.GetImportName(ctx, info.Selector, info.Path, r) @@ -1239,6 +1245,11 @@ module Util = else mkGenericPathExpr (splitNameParts ident.Name) None + let isThisArgumentIdentExpr (expr: Fable.Expr) = + match expr with + | Fable.IdentExpr ident -> ident.IsThisArgument + | _ -> false + // let transformExprMaybeIdentExpr (com: IRustCompiler) ctx (expr: Fable.Expr) = // match expr with // | Fable.IdentExpr ident when ident.IsThisArgument -> @@ -1596,7 +1607,9 @@ module Util = let prepareRefForPatternMatch (com: IRustCompiler) ctx typ (name: string option) fableExpr = let expr = com.TransformExpr(ctx, fableExpr) - if (name.IsSome && isRefScoped ctx name.Value) || (isInRefType com typ) then + if isThisArgumentIdentExpr fableExpr then + expr + elif (name.IsSome && isRefScoped ctx name.Value) || (isInRefType com typ) then expr elif shouldBeRefCountWrapped com ctx typ |> Option.isSome then expr |> makeAsRef @@ -2037,6 +2050,24 @@ module Util = // | None, _ -> // None + let getDeclMember (com: IRustCompiler) (decl: Fable.MemberDecl) = + decl.ImplementedSignatureRef + |> Option.defaultValue decl.MemberRef + |> com.GetMember + + let getDistinctInterfaceMembers (com: IRustCompiler) (ent: Fable.Entity) = + assert (ent.IsInterface) + + FSharp2Fable.Util.getInterfaceMembers com ent + |> Seq.filter (fun (ifc, memb) -> not memb.IsProperty) + |> Seq.distinctBy (fun (ifc, memb) -> memb.CompiledName) // skip inherited overwrites + + let getInterfaceMemberNames (com: IRustCompiler) (entRef: Fable.EntityRef) = + let ent = com.GetEntity(entRef) + + getDistinctInterfaceMembers com ent + |> Seq.map (fun (ifc, memb) -> memb.FullName) + |> Set.ofSeq let makeObjectExprMemberDecl (com: IRustCompiler) ctx (memb: Fable.ObjectExprMember) = let capturedIdents = getCapturedIdents com ctx (Some memb.Name) memb.Args memb.Body @@ -2110,7 +2141,21 @@ module Util = memberDecl ) - let fieldIdents = fieldsMap.Values |> Seq.toList + let decl: Fable.ClassDecl = + { + Name = entName + Entity = entRef + Constructor = None + BaseCall = baseCall + AttachedMembers = members + XmlDoc = None + Tags = [] + } + + let fieldIdents = + fieldsMap.Values + |> Seq.map (fun ident -> { ident with Type = FableTransforms.uncurryType ident.Type }) + |> Seq.toList let fields = fieldIdents @@ -2120,6 +2165,14 @@ module Util = mkField [] fieldName fieldTy false ) + let exprFields = + fieldIdents + |> List.map (fun ident -> + let expr = transformIdent com ctx None ident |> makeClone + let fieldName = ident.Name |> sanitizeMember + mkExprField [] fieldName expr false false + ) + let attrs = [ mkAttr "derive" (makeDerivedFrom com ent) ] let generics = makeGenerics com ctx genArgs let genParams = FSharp2Fable.Util.getGenParamTypes genArgs @@ -2130,36 +2183,24 @@ module Util = else [ mkStructItem attrs entName fields generics ] - let ctx = { ctx with ScopedEntityGenArgs = getEntityGenParamNames ent } - - let memberItems = - members - |> List.map (fun decl -> decl, com.GetMember(decl.MemberRef)) - |> List.filter (fun (d, m) -> isInterfaceMember com entRef m) - |> List.distinctBy (fun (d, m) -> Fable.Naming.splitLast m.CompiledName) - |> List.map (makeMemberItem com ctx false) - |> makeInterfaceTraitImpls com ctx entName genParams entRef genArgs - - let exprFields = - fieldIdents - |> List.map (fun ident -> - let expr = transformIdent com ctx None ident |> makeClone - let fieldName = ident.Name |> sanitizeMember - mkExprField [] fieldName expr false false - ) + let memberItems = transformClassMembers com ctx genArgs decl let objExpr = - match baseCall with - | Some fableExpr -> com.TransformExpr(ctx, fableExpr) - | None -> - let genArgsOpt = transformGenArgs com ctx genParams - let path = makeFullNamePath entName genArgsOpt - let expr = mkStructExpr path exprFields |> makeLrcPtrValue com ctx + // match baseCall with + // | Some fableExpr -> com.TransformExpr(ctx, fableExpr) //TODO: + // | None -> + let genArgsOpt = transformGenArgs com ctx genParams + let path = makeFullNamePath entName genArgsOpt + let expr = mkStructExpr path exprFields |> makeLrcPtrValue com ctx + + if ent.IsInterface then makeInterfaceCast com ctx typ expr + else + expr - let objStmt = objExpr |> mkExprStmt let declStmts = structItems @ memberItems |> List.map mkItemStmt - declStmts @ [ objStmt ] |> mkBlock |> mkBlockExpr + let objStmts = [ objExpr |> mkExprStmt ] + declStmts @ objStmts |> mkBlock |> mkBlockExpr let maybeAddParens fableExpr (expr: Rust.Expr) : Rust.Expr = match fableExpr with @@ -2338,9 +2379,9 @@ module Util = mkCallExpr callee [] |> mutableGet else mkCallExpr callee args - | None, Fable.LibraryImport memberInfo -> + | None, Fable.LibraryImport mi -> let genArgsOpt = - if needGenArgs && memberInfo.IsModuleMember then + if needGenArgs && (mi.IsModuleMember || not mi.IsInstanceMember) then match typ with | Fable.Tuple _ -> transformGenArgs com ctx [ typ ] | _ -> transformGenArgs com ctx typ.Generics @@ -3678,7 +3719,7 @@ module Util = | Fable.Constraint.CoercesTo(targetType) -> match targetType with | IFormattable -> [ makeGenBound ("core" :: "fmt" :: "Display" :: []) [] ] - | IEquatable _ -> [ makeRawBound "Eq"; makeGenBound ("core" :: "hash" :: "Hash" :: []) [] ] + | IEquatable _ -> [ makeGenBound ("core" :: "hash" :: "Hash" :: []) []; makeRawBound "PartialEq" ] | Fable.DeclaredType(entRef, genArgs) -> let ent = com.GetEntity(entRef) @@ -3697,8 +3738,8 @@ module Util = | Fable.Constraint.HasComparison -> [ makeRawBound "PartialOrd" ] | Fable.Constraint.HasEquality -> [ - makeRawBound "Eq" // "PartialEq" makeGenBound ("core" :: "hash" :: "Hash" :: []) [] + makeRawBound "PartialEq" // "Eq" ] | Fable.Constraint.IsUnmanaged -> [] | Fable.Constraint.IsEnum -> [] @@ -4041,25 +4082,6 @@ module Util = let fnItem = mkFnAssocItem attrs name fnKind fnItem - let isInterfaceMember (com: IRustCompiler) (entRef: Fable.EntityRef) (memb: Fable.MemberFunctionOrValue) = - let ent = com.GetEntity(entRef) - assert (ent.IsInterface) - - match memb.DeclaringEntity with - | Some declEntRef -> - let declEnt = com.GetEntity(declEntRef) - - if declEnt.IsInterface then - ent.AllInterfaces |> Seq.exists (fun ifc -> ifc.Entity = declEntRef) - else - // if declaring entity is not an interface, the interface is in the member.CompiledName - let ifcName, membName = Fable.Naming.splitLastBy "." memb.CompiledName - let ifcName, _ = Fable.Naming.splitFirstBy "<" ifcName // trim the generics - - ent.AllInterfaces - |> Seq.exists (fun ifc -> ifc.Entity.FullName.StartsWith(ifcName)) - | None -> false - let makeDerivedFrom com (ent: Fable.Entity) = let isCopyable = ent |> isCopyableEntity com Set.empty let isPrintable = ent |> isPrintableEntity com Set.empty @@ -4255,12 +4277,7 @@ module Util = fnItem let makeInterfaceItems (com: IRustCompiler) ctx hasBody typeName (ent: Fable.Entity) = - assert (ent.IsInterface) - - ent - |> FSharp2Fable.Util.getInterfaceMembers com - |> Seq.filter (fun (ifc, memb) -> memb.IsDispatchSlot) // TODO: is that needed? - |> Seq.distinctBy (fun (ifc, memb) -> Fable.Naming.splitLast memb.CompiledName) // skip inherited overwrites + getDistinctInterfaceMembers com ent |> Seq.map (fun (ifc, memb) -> let ifcEnt = com.GetEntity(ifc.Entity) let ifcTyp = Fable.DeclaredType(ifc.Entity, ifc.GenericArgs) @@ -4366,7 +4383,7 @@ module Util = else [] - let makeDisplayTraitImpls com ctx self_ty genArgs hasToString = + let makeDisplayTraitImpls com ctx entName genArgs hasToString = // expected output: // impl core::fmt::Display for {self_ty} { // fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -4397,17 +4414,11 @@ module Util = let fnKind = mkFnKind DEFAULT_FN_HEADER fnDecl NO_GENERICS fnBody let fnItem = mkFnAssocItem [] "fmt" fnKind - let generics = makeGenerics com ctx genArgs - let implItemFor traitName = - let path = mkGenericPath ("core" :: "fmt" :: traitName :: []) None - let ofTrait = mkTraitRef path |> Some - mkImplItem [] "" self_ty generics [ fnItem ] ofTrait + let path = mkGenericPath ("core" :: "fmt" :: "Display" :: []) None + let ofTrait = mkTraitRef path |> Some - [ - // implItemFor "Debug" - implItemFor "Display" - ] + makeTraitImpls com ctx entName genArgs ofTrait [ fnItem ] let op_impl_map = Map @@ -4433,40 +4444,47 @@ module Util = com ctx (ent: Fable.Entity) - entType - self_ty - genArgTys - (decl: Fable.MemberDecl, memb: Fable.MemberFunctionOrValue) + entName + genArgs + (members: (Fable.MemberDecl * Fable.MemberFunctionOrValue) list) = - op_impl_map - |> Map.tryFind memb.CompiledName - |> Option.filter (fun _ -> - // TODO: more checks if parameter types match the operator? - ent.IsValueType - && not (memb.IsInstance) // operators are static - && decl.Args.Head.Type = entType - && decl.Body.Type = entType - ) - |> Option.map (fun (op_macro, op_trait, op_fn) -> - let rhs_tys = - decl.Args.Tail - |> List.map (fun arg -> - if arg.Type = entType then - mkImplSelfTy () - else - arg.Type |> transformType com ctx - ) + let entType = FSharp2Fable.Util.getEntityType ent + let genArgTys = transformGenTypes com ctx genArgs + let genArgsOpt = transformGenArgs com ctx genArgs + let self_ty = makeFullNamePathTy entName genArgsOpt + + members + |> List.choose (fun (decl, memb) -> + op_impl_map + |> Map.tryFind memb.CompiledName + |> Option.filter (fun _ -> + // TODO: more checks if parameter types match the operator? + ent.IsValueType + && not (memb.IsInstance) // operators are static + && decl.Args.Head.Type = entType + && decl.Body.Type = entType + ) + |> Option.map (fun (op_macro, op_trait, op_fn) -> + let rhs_tys = + decl.Args.Tail + |> List.map (fun arg -> + if arg.Type = entType then + mkImplSelfTy () + else + arg.Type |> transformType com ctx + ) - let macroName = getLibraryImportName com ctx "Native" op_macro - let id_tokens = [ op_trait; op_fn; decl.Name ] |> List.map mkIdentToken - let ty_tokens = (self_ty :: rhs_tys) @ genArgTys |> List.map mkTyToken + let macroName = getLibraryImportName com ctx "Native" op_macro + let id_tokens = [ op_trait; op_fn; decl.Name ] |> List.map mkIdentToken + let ty_tokens = (self_ty :: rhs_tys) @ genArgTys |> List.map mkTyToken - let implItem = - id_tokens @ ty_tokens - |> mkParensCommaDelimitedMacCall macroName - |> mkMacCallItem [] "" + let implItem = + id_tokens @ ty_tokens + |> mkParensCommaDelimitedMacCall macroName + |> mkMacCallItem [] "" - implItem + implItem + ) ) let withCurrentScope ctx (usedNames: Set) f = @@ -4487,7 +4505,7 @@ module Util = else memberItem - let makePrimaryConstructorItems com ctx (ent: Fable.Entity) (decl: Fable.ClassDecl) = + let makePrimaryConstructorItems com ctx (ent: Fable.Entity) (declOpt: Fable.MemberDecl option) = if ent.IsFSharpUnion || ent.IsFSharpRecord @@ -4497,7 +4515,7 @@ module Util = [] else let ctorItem = - match decl.Constructor with + match declOpt with | Some ctor -> withCurrentScope ctx ctor.UsedNames <| fun ctx -> transformPrimaryConstructor com ctx ent ctor @@ -4505,114 +4523,124 @@ module Util = [ ctorItem ] - let makeInterfaceTraitImpls (com: IRustCompiler) ctx entName genArgs ifcEntRef ifcGenArgs memberItems = + let makeTraitImpls (com: IRustCompiler) ctx entName genArgs ofTrait memberItems = let genArgsOpt = transformGenArgs com ctx genArgs let traitBound = mkTypeTraitGenericBound [ entName ] genArgsOpt - let ty = mkTraitTy [ traitBound ] + let self_ty = mkTraitTy [ traitBound ] let generics = makeGenerics com ctx genArgs + let implItem = mkImplItem [] "" self_ty generics memberItems ofTrait + [ implItem ] - let ifcFullName = ifcEntRef |> getEntityFullName com ctx - let ifcGenArgsOpt = ifcGenArgs |> transformGenArgs com ctx - + let makeInterfaceTraitImpls (com: IRustCompiler) ctx entName genArgs ifcEntRef ifcGenArgs memberItems = + let ifcFullName = getEntityFullName com ctx ifcEntRef + let ifcGenArgsOpt = transformGenArgs com ctx ifcGenArgs let path = makeFullNamePath ifcFullName ifcGenArgsOpt let ofTrait = mkTraitRef path |> Some - let implItem = mkImplItem [] "" ty generics memberItems ofTrait - [ implItem ] - - let objectMemberNames = - set - [ - "Equals" - "GetHashCode" - "GetType" - "ToString" - // "MemberwiseClone" - // "ReferenceEquals" - ] + memberItems |> makeTraitImpls com ctx entName genArgs ofTrait + + // let objectMemberNames = + // set + // [ + // // "Equals" + // // "GetHashCode" + // // "MemberwiseClone" + // // "ReferenceEquals" + // "GetType" + // "ToString" + // ] let ignoredInterfaceNames = set [ Types.ienumerable; Types.ienumerator ] - let getAllInterfaces (ent: Fable.Entity) : Fable.DeclaredType list = - ent.AllInterfaces - |> Seq.filter (fun ifc -> - // throws out anything on the ignored interfaces list - not (Set.contains ifc.Entity.FullName ignoredInterfaceNames) - ) - |> Seq.toList + let getDeclaringEntities (members: Fable.MemberFunctionOrValue list) = + members + |> List.choose (fun memb -> memb.DeclaringEntity) + |> List.distinctBy (fun entRef -> entRef.FullName) - let transformClassMembers (com: IRustCompiler) ctx (classDecl: Fable.ClassDecl) = + let transformClassMembers (com: IRustCompiler) ctx genArgs (classDecl: Fable.ClassDecl) = let entRef = classDecl.Entity let ent = com.GetEntity(entRef) + let isObjectExpr = ent.IsInterface || ent.FullName = "System.Object" + let entName = - if ent.IsInterface then + if isObjectExpr then classDecl.Name else - getEntityFullName com ctx entRef - |> Fable.Naming.splitLast + getEntityFullName com ctx entRef |> Fable.Naming.splitLast - let entType = FSharp2Fable.Util.getEntityType ent - let genArgs = FSharp2Fable.Util.getEntityGenArgs ent - let self_ty = transformEntityType com ctx entRef genArgs - let genArgTys = transformGenTypes com ctx genArgs + let genParams = FSharp2Fable.Util.getGenParamTypes genArgs let ctx = { ctx with ScopedEntityGenArgs = getEntityGenParamNames ent } - // to filter out compiler-generated exception equality - let isNotExceptionMember (_m: Fable.MemberFunctionOrValue) = not (ent.IsFSharpExceptionDeclaration) + let isIgnoredMember (memb: Fable.MemberFunctionOrValue) = ent.IsFSharpExceptionDeclaration // to filter out compiler-generated exception equality - let isNonInterfaceMember (m: Fable.MemberFunctionOrValue) = - m.IsConstructor - || (not ent.IsInterface && not m.IsOverrideOrExplicitInterfaceImplementation) - || (not ent.IsInterface && Set.contains m.CompiledName objectMemberNames) + let isInterfaceMember (memb: Fable.MemberFunctionOrValue) = + (memb.IsDispatchSlot || memb.IsOverrideOrExplicitInterfaceImplementation) + && (memb.DeclaringEntity + |> Option.bind com.TryGetEntity + |> Option.map (fun ent -> ent.IsInterface) + |> Option.defaultValue false) + // || memb.IsOverrideOrExplicitInterfaceImplementation) + // && not (Set.contains memb.CompiledName objectMemberNames) - let nonInterfaceMembers, interfaceMembers = + let interfaceMembers, nonInterfaceMembers = classDecl.AttachedMembers - |> List.map (fun decl -> decl, com.GetMember(decl.MemberRef)) - |> List.partition (snd >> isNonInterfaceMember) + |> List.map (fun decl -> decl, getDeclMember com decl) + |> List.partition (snd >> isInterfaceMember) let nonInterfaceImpls = let memberItems = nonInterfaceMembers - |> List.filter (snd >> isNotExceptionMember) + |> List.filter (snd >> isIgnoredMember >> not) |> List.map (makeMemberItem com ctx true) - |> List.append (makeFSharpExceptionItems com ctx ent) - |> List.append (makePrimaryConstructorItems com ctx ent classDecl) + + let memberItems = + if isObjectExpr then + memberItems + else + memberItems + |> List.append (makeFSharpExceptionItems com ctx ent) + |> List.append (makePrimaryConstructorItems com ctx ent classDecl.Constructor) if List.isEmpty memberItems then [] else - let generics = makeGenerics com ctx genArgs - let implItem = mkImplItem [] "" self_ty generics memberItems None - [ implItem ] - - let nonInterfaceMemberNames = - nonInterfaceMembers |> List.map (fun (d, m) -> d.Name) |> Set.ofList + memberItems |> makeTraitImpls com ctx entName genArgs None let displayTraitImpls = - if ent.IsInterface then - [] - else - let hasToString = Set.contains "ToString" nonInterfaceMemberNames - makeDisplayTraitImpls com ctx self_ty genArgs hasToString + let hasToString = + nonInterfaceMembers |> List.exists (fun (d, m) -> m.CompiledName = "ToString") + + makeDisplayTraitImpls com ctx entName genParams hasToString let operatorTraitImpls = - nonInterfaceMembers - |> List.choose (makeOpTraitImpls com ctx ent entType self_ty genArgTys) + nonInterfaceMembers |> makeOpTraitImpls com ctx ent entName genArgs let interfaceTraitImpls = - getAllInterfaces ent - |> List.collect (fun ifc -> + interfaceMembers + |> List.map snd + |> getDeclaringEntities + |> List.filter (fun ifcEntRef -> + // throws out anything on the ignored interfaces list + not (ignoredInterfaceNames |> Set.contains ifcEntRef.FullName) + ) + |> List.collect (fun ifcEntRef -> + let ifcGenArgs = + if ent.IsInterface then + genArgs + else + let ifcEnt = com.GetEntity(ifcEntRef) + FSharp2Fable.Util.getEntityGenArgs ifcEnt + + let memberNames = getInterfaceMemberNames com ifcEntRef + let memberItems = interfaceMembers - |> List.filter (fun (d, m) -> isInterfaceMember com ifc.Entity m) - |> List.distinctBy (fun (d, m) -> Fable.Naming.splitLast m.CompiledName) + |> List.filter (fun (d, m) -> Set.contains m.FullName memberNames) |> List.map (makeMemberItem com ctx false) - if List.isEmpty memberItems then - [] - else - makeInterfaceTraitImpls com ctx entName genArgs ifc.Entity ifc.GenericArgs memberItems + memberItems + |> makeInterfaceTraitImpls com ctx entName genParams ifcEntRef ifcGenArgs ) nonInterfaceImpls @ displayTraitImpls @ operatorTraitImpls @ interfaceTraitImpls @@ -4632,7 +4660,8 @@ module Util = transformClass com ctx ent decl |> entityItemWithVis com ctx ent - let memberItems = transformClassMembers com ctx decl + let genArgs = FSharp2Fable.Util.getEntityGenArgs ent + let memberItems = transformClassMembers com ctx genArgs decl entityItem :: memberItems let getVis (com: IRustCompiler) ctx declaringEntity isInternal isPrivate = diff --git a/src/Fable.Transforms/Rust/Replacements.fs b/src/Fable.Transforms/Rust/Replacements.fs index 7067904f6..c6788df94 100644 --- a/src/Fable.Transforms/Rust/Replacements.fs +++ b/src/Fable.Transforms/Rust/Replacements.fs @@ -147,6 +147,15 @@ let makeRefFromMutableFunc com ctx r t (value: Expr) = value let toNativeIndex expr = TypeCast(expr, UNativeInt.Number) +let toLowerFirstWithArgsCountSuffix (args: Expr list) meth = + let argCount = List.length args + let meth = Naming.lowerFirst meth + + if argCount > 1 then + meth + (string argCount) + else + meth + let toChar com (arg: Expr) = match arg.Type with | Char -> arg @@ -338,7 +347,6 @@ let emitFormat (com: ICompiler) r t (args: Expr list) macro = let unboxedArgs = args |> FSharp2Fable.Util.unboxBoxedArgs Helper.LibCall(com, "String", macro, t, unboxedArgs) - let getMut expr = Helper.InstanceCall(expr, "get_mut", expr.Type, []) @@ -1601,79 +1609,39 @@ let seqModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (thisArg let resizeArrays (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (thisArg: Expr option) (args: Expr list) = match i.CompiledName, thisArg, args with - | ".ctor", _, [] -> - // makeArray (getElementType t) [] |> Some - Helper.LibCall(com, "NativeArray", "new_empty", t, [], ?loc = r) |> Some - | ".ctor", _, [ ExprTypeAs(Number(Int32, _), idx) ] -> - Helper.LibCall(com, "NativeArray", "new_with_capacity", t, [ idx ], ?loc = r) - |> Some - // Optimize expressions like `ResizeArray [|1|]` or `ResizeArray [1]` - | ".ctor", _, [ ArrayOrListLiteral(vals, typ) ] -> makeArray typ vals |> Some + | ".ctor", _, [] -> Helper.LibCall(com, "NativeArray", "new_empty", t, args, ?loc = r) |> Some + | ".ctor", _, [ ExprType(Number(Int32, _)) ] -> + Helper.LibCall(com, "NativeArray", "new_with_capacity", t, args, ?loc = r) + |> Some + | ".ctor", _, [ ExprType(IEnumerable) ] -> + Helper.LibCall(com, "NativeArray", "new_from_enumerable", t, args, ?loc = r) + |> Some | ".ctor", _, [ arg ] -> toArray com t arg |> Some + | "get_Capacity", Some ar, _ -> Helper.LibCall(com, "NativeArray", "get_Capacity", t, [ ar ], ?loc = r) |> Some + | "get_Count", Some ar, _ -> Helper.LibCall(com, "NativeArray", "get_Count", t, [ ar ], ?loc = r) |> Some | "get_Item", Some ar, [ idx ] -> getExpr r t ar idx |> Some | "set_Item", Some ar, [ idx; value ] -> setExpr r ar idx value |> Some - | "Add", Some(MaybeCasted(ar)), [ arg ] -> - Helper.LibCall(com, "NativeArray", "add", t, [ ar; arg ], ?loc = r) |> Some - | "Remove", Some(MaybeCasted(ar)), [ arg ] -> - Helper.LibCall(com, "Array", "removeInPlace", t, [ arg; ar ], ?loc = r) |> Some - | "RemoveAll", Some ar, [ arg ] -> - Helper.LibCall(com, "Array", "removeAllInPlace", t, [ arg; ar ], ?loc = r) - |> Some - | "FindIndex", Some ar, [ arg ] -> - Helper.LibCall(com, "NativeArray", "FindIndex", t, [ ar; arg ], ?loc = r) - |> Some - | "FindLastIndex", Some ar, [ arg ] -> - Helper.LibCall(com, "Array", "findLastIndex", t, [ arg; ar ], ?loc = r) |> Some - | "ForEach", Some ar, [ arg ] -> makeInstanceCall r t i ar "forEach" [ arg ] |> Some | "GetEnumerator", Some(MaybeCasted(ar)), _ -> Helper.LibCall(com, "Seq", "Enumerable::ofArray", t, [ ar ], ?loc = r) |> Some - | "get_Count", Some(MaybeCasted(ar)), _ -> Helper.LibCall(com, "NativeArray", "count", t, [ ar ], ?loc = r) |> Some - | "Clear", Some(MaybeCasted(ar)), [] -> makeInstanceCall r t i (getMut ar) "clear" [] |> Some - | "ConvertAll", Some ar, [ arg ] -> Helper.LibCall(com, "Array", "map", t, [ arg; ar ], ?loc = r) |> Some - | "Find", Some ar, [ arg ] -> - let opt = Helper.LibCall(com, "Array", "tryFind", t, [ arg; ar ], ?loc = r) - - Helper.LibCall(com, "Option", "defaultArg", t, [ opt; getZero com ctx t ], ?loc = r) - |> Some - | "Exists", Some ar, [ arg ] -> - Helper.LibCall(com, "Array", "exists", t, [ arg; ar ], i.SignatureArgTypes, ?loc = r) - |> Some - | "FindLast", Some ar, [ arg ] -> - let opt = Helper.LibCall(com, "Array", "tryFindBack", t, [ arg; ar ], ?loc = r) - - Helper.LibCall(com, "Option", "defaultArg", t, [ opt; getZero com ctx t ], ?loc = r) - |> Some - | "FindAll", Some ar, [ arg ] -> Helper.LibCall(com, "Array", "filter", t, [ arg; ar ], ?loc = r) |> Some - | "AddRange", Some ar, [ arg ] -> - Helper.LibCall(com, "Array", "addRangeInPlace", t, [ arg; ar ], ?loc = r) - |> Some - | "GetRange", Some ar, [ idx; cnt ] -> - Helper.LibCall(com, "Array", "getSubArray", t, [ ar; idx; cnt ], ?loc = r) - |> Some - | "Contains", Some(MaybeCasted(ar)), [ arg ] -> - Helper.LibCall(com, "Array", "contains", t, [ arg; ar ], i.SignatureArgTypes, ?loc = r) - |> Some - | "IndexOf", Some ar, [ arg ] -> - Helper.LibCall(com, "Array", "indexOf", t, [ ar; arg ], i.SignatureArgTypes, ?loc = r) - |> Some - | "Insert", Some ar, [ idx; arg ] -> makeInstanceCall r t i (getMut ar) "insert" [ toNativeIndex idx; arg ] |> Some - | "InsertRange", Some ar, [ idx; arg ] -> - Helper.LibCall(com, "Array", "insertRangeInPlace", t, [ idx; arg; ar ], ?loc = r) - |> Some - | "RemoveRange", Some ar, args -> makeInstanceCall r t i ar "splice" args |> Some - | "RemoveAt", Some ar, [ idx ] -> makeInstanceCall r t i (getMut ar) "remove" [ toNativeIndex idx ] |> Some - | "Reverse", Some ar, [] -> makeInstanceCall r t i (getMut ar) "reverse" args |> Some - | "Sort", Some ar, [] -> - // can't use .sort() as it needs T: Ord - Helper.LibCall(com, "Array", "sortInPlace", t, [ ar ], i.SignatureArgTypes, ?loc = r) + | ("Add" | "AddRange" | "Clear" | "Contains" | "ConvertAll" | "Exists" | "GetRange" | "Slice" | "ForEach" | "FindAll" | "Find" | "FindLast" | "FindIndex" | "FindLastIndex" | "Insert" | "InsertRange" | "Remove" | "RemoveAt" | "RemoveAll" | "RemoveRange" | "ToArray" | "TrimExcess" | "TrueForAll") as meth, + Some ar, + args -> + // methods without overrides + let meth = Naming.lowerFirst meth + Helper.LibCall(com, "NativeArray", meth, t, (ar :: args), ?loc = r) |> Some + | ("BinarySearch" | "CopyTo" | "IndexOf" | "LastIndexOf" | "Reverse") as meth, Some ar, args -> + // methods with some overrides + let meth = meth |> toLowerFirstWithArgsCountSuffix args + Helper.LibCall(com, "NativeArray", meth, t, (ar :: args), ?loc = r) |> Some + | "Sort", Some ar, [] -> Helper.LibCall(com, "NativeArray", "sort", t, (ar :: args), ?loc = r) |> Some + | "Sort", Some ar, [ ExprType(DelegateType _) ] -> + Helper.LibCall(com, "NativeArray", "sortBy", t, (ar :: args), ?loc = r) |> Some + | "Sort", Some ar, [ comparer ] -> + Helper.LibCall(com, "NativeArray", "sortWith", t, (ar :: args), ?loc = r) + |> Some + | "Sort", Some ar, [ index; count; comparer ] -> + Helper.LibCall(com, "NativeArray", "sortWith2", t, (ar :: args), ?loc = r) |> Some - | "Sort", Some ar, [ ExprType(DelegateType _) as comparer ] -> - let cmp = Helper.LibCall(com, "Native", "makeCompare", t, [ comparer ], ?loc = r) - - makeInstanceCall r t i (getMut ar) "sort_by" [ cmp ] |> Some - // | "Sort", Some ar, [arg] -> - // Helper.LibCall(com, "Array", "sortInPlaceWithComparer", t, [ar; arg], i.SignatureArgTypes, ?loc=r) |> Some - | "ToArray", Some ar, [] -> Helper.LibCall(com, "NativeArray", "new_copy", t, [ ar ], ?loc = r) |> Some | _ -> None let collectionExtensions @@ -1743,30 +1711,22 @@ let copyToArray (com: ICompiler) r t (i: CallInfo) args = let arrays (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (thisArg: Expr option) (args: Expr list) = match i.CompiledName, thisArg, args with - | "get_Length", Some ar, _ -> Helper.LibCall(com, "NativeArray", "count", t, [ ar ], ?loc = r) |> Some + | "get_Length", Some ar, _ -> Helper.LibCall(com, "NativeArray", "get_Count", t, [ ar ], ?loc = r) |> Some | "get_Item", Some ar, [ idx ] -> getExpr r t ar idx |> Some | "set_Item", Some ar, [ idx; value ] -> setExpr r ar idx value |> Some - | "Clone", Some ar, _ -> Helper.LibCall(com, "NativeArray", "new_copy", t, [ ar ], ?loc = r) |> Some + | "Clone", Some ar, _ -> Helper.LibCall(com, "NativeArray", "toArray", t, [ ar ], ?loc = r) |> Some | "Copy", None, [ _source; _sourceIndex; _target; _targetIndex; _count ] -> copyToArray com r t i args | "Copy", None, [ source; target; count ] -> copyToArray com r t i [ source; makeIntConst 0; target; makeIntConst 0; count ] | "ConvertAll", None, [ source; mapping ] -> - Helper.LibCall(com, "Array", "map", t, [ mapping; source ], ?loc = r) |> Some - | "IndexOf", None, [ ar; arg ] -> - Helper.LibCall(com, "Array", "indexOf", t, args, i.SignatureArgTypes, ?loc = r) - |> Some + Helper.LibCall(com, "NativeArray", "convertAll", t, args, ?loc = r) |> Some + | "IndexOf", None, [ ar; arg ] -> Helper.LibCall(com, "NativeArray", "indexOf", t, args, ?loc = r) |> Some | "GetEnumerator", Some ar, _ -> Helper.LibCall(com, "Seq", "Enumerable::ofArray", t, [ ar ], ?loc = r) |> Some - | "Reverse", None, [ ar ] -> makeInstanceCall r t i (getMut ar) "reverse" [] |> Some - | "Sort", None, [ ar ] -> - // can't use .sort() as it needs T: Ord - Helper.LibCall(com, "Array", "sortInPlace", t, [ ar ], i.SignatureArgTypes, ?loc = r) - |> Some + | "Reverse", None, [ ar ] -> Helper.LibCall(com, "NativeArray", "reverse", t, args, ?loc = r) |> Some + | "Sort", None, [ ar ] -> Helper.LibCall(com, "NativeArray", "sort", t, args, ?loc = r) |> Some | "Sort", None, [ ar; ExprType(DelegateType _) as comparer ] -> - let cmp = Helper.LibCall(com, "Native", "makeCompare", t, [ comparer ], ?loc = r) - - makeInstanceCall r t i (getMut ar) "sort_by" [ cmp ] |> Some - // | "Sort", None, [ar; arg] -> - // Helper.LibCall(com, "Array", "sortInPlaceWithComparer", t, [ar; arg], i.SignatureArgTypes, ?loc=r) |> Some + Helper.LibCall(com, "NativeArray", "sortBy", t, args, ?loc = r) |> Some + | "Sort", None, [ ar; comparer ] -> Helper.LibCall(com, "NativeArray", "sortWith", t, args, ?loc = r) |> Some | _ -> None let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Expr option) (args: Expr list) = @@ -1783,7 +1743,7 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex | "ToList", args -> Helper.LibCall(com, "List", "ofArray", t, args, i.SignatureArgTypes, ?loc = r) |> Some - | ("Length" | "Count"), [ ar ] -> Helper.LibCall(com, "NativeArray", "count", t, [ ar ], ?loc = r) |> Some + | ("Length" | "Count"), [ ar ] -> Helper.LibCall(com, "NativeArray", "get_Count", t, [ ar ], ?loc = r) |> Some | "Item", [ idx; ar ] -> getExpr r t ar idx |> Some | "Get", [ ar; idx ] -> getExpr r t ar idx |> Some | "Set", [ ar; idx; value ] -> setExpr r ar idx value |> Some @@ -1792,9 +1752,7 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex | "Empty", [] -> createArray com ctx r t i (makeIntConst 0) None |> Some | "Singleton", [ value ] -> createArray com ctx r t i (makeIntConst 1) (Some value) |> Some | "IsEmpty", [ ar ] -> makeInstanceCall r t i ar "is_empty" [] |> Some - | "Copy", [ ar ] -> - Helper.LibCall(com, "NativeArray", "new_copy", t, args, i.SignatureArgTypes, ?loc = r) - |> Some + | "Copy", [ ar ] -> Helper.LibCall(com, "NativeArray", "toArray", t, args, ?loc = r) |> Some | "CopyTo", args -> copyToArray com r t i args | ("Concat" | "Transpose" as meth), [ arg ] -> Helper.LibCall(com, "Array", Naming.lowerFirst meth, t, [ toArray com t arg ], i.SignatureArgTypes, ?loc = r) diff --git a/src/fable-compiler-js/package-lock.json b/src/fable-compiler-js/package-lock.json index 538d0113d..ed3e01192 100644 --- a/src/fable-compiler-js/package-lock.json +++ b/src/fable-compiler-js/package-lock.json @@ -383,9 +383,9 @@ "integrity": "sha512-CH1qg/1DxRQ0HF/mvzFN/19+5txRSfI6HL+MqA1S+ZQk7NKVLChHRXJdWLfqg9d//lzLI4Vh24X/598iX6E1Xg==" }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.2.0.tgz", - "integrity": "sha512-8PlggAxGxavr+pkCNeV1TM2wTb2o+cUWDg9M1cm9nR27Dsn287uZtSLYXoQqQcmq+sYfF7lHfd3sWJJinH9GmA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], @@ -396,9 +396,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.2.0.tgz", - "integrity": "sha512-+71T85hbMFrJI+zKQULNmSYBeIhru55PYoF/u75MyeN2FcxE4HSPw20319b+FcZ4lWx2Nx/Ql9tN+hoaD3GH/A==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], @@ -409,9 +409,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.2.0.tgz", - "integrity": "sha512-IIIQLuG43QIElT1JZqUP/zqIdiJl4t9U/boa0GZnQTw9m1X0k3mlBuysbgYXeloLT1RozdL7bgw4lpSaI8GOXw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], @@ -422,9 +422,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.2.0.tgz", - "integrity": "sha512-BXcXvnLaea1Xz900omrGJhxHFJfH9jZ0CpJuVsbjjhpniJ6qiLXz3xA8Lekaa4MuhFcJd4f0r+Ky1G4VFbYhWw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], @@ -435,9 +435,22 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.2.0.tgz", - "integrity": "sha512-f4K3MKw9Y4AKi4ANGnmPIglr+S+8tO858YrGVuqAHXxJdVghBmz9CPU9kDpOnGvT4g4vg5uNyIFpOOFvffXyMA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "cpu": [ "arm" ], @@ -448,9 +461,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.2.0.tgz", - "integrity": "sha512-bNsTYQBgp4H7w6cT7FZhesxpcUPahsSIy4NgdZjH1ZwEoZHxi4XKglj+CsSEkhsKi+x6toVvMylhjRKhEMYfnA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], @@ -461,9 +474,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.2.0.tgz", - "integrity": "sha512-Jp1NxBJpGLuxRU2ihrQk4IZ+ia5nffobG6sOFUPW5PMYkF0kQtxEbeDuCa69Xif211vUOcxlOnf5IOEIpTEySA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], @@ -473,10 +486,49 @@ "linux" ] }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.2.0.tgz", - "integrity": "sha512-3p3iRtQmv2aXw+vtKNyZMLOQ+LSRsqArXjKAh2Oj9cqwfIRe7OXvdkOzWfZOIp1F/x5KJzVAxGxnniF4cMbnsQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], @@ -487,9 +539,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.2.0.tgz", - "integrity": "sha512-atih7IF/reUZe4LBLC5Izd44hth2tfDIG8LaPp4/cQXdHh9jabcZEvIeRPrpDq0i/Uu487Qu5gl5KwyAnWajnw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], @@ -500,9 +552,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.2.0.tgz", - "integrity": "sha512-vYxF3tKJeUE4ceYzpNe2p84RXk/fGK30I8frpRfv/MyPStej/mRlojztkN7Jtd1014HHVeq/tYaMBz/3IxkxZw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], @@ -513,9 +565,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.2.0.tgz", - "integrity": "sha512-1LZJ6zpl93SaPQvas618bMFarVwufWTaczH4ESAbFcwiC4OtznA6Ym+hFPyIGaJaGEB8uMWWac0uXGPXOg5FGA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], @@ -526,9 +578,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.2.0.tgz", - "integrity": "sha512-dgQfFdHCNg08nM5zBmqxqc9vrm0DVzhWotpavbPa0j4//MAOKZEB75yGAfzQE9fUJ+4pvM1239Y4IhL8f6sSog==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], @@ -538,6 +590,12 @@ "win32" ] }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/esbuild": { "version": "0.19.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", @@ -590,10 +648,13 @@ } }, "node_modules/rollup": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.2.0.tgz", - "integrity": "sha512-deaMa9Z+jPVeBD2dKXv+h7EbdKte9++V2potc/ADqvVgEr6DEJ3ia9u0joarjC2lX/ubaCRYz3QVx0TzuVqAJA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, + "dependencies": { + "@types/estree": "1.0.5" + }, "bin": { "rollup": "dist/bin/rollup" }, @@ -602,18 +663,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.2.0", - "@rollup/rollup-android-arm64": "4.2.0", - "@rollup/rollup-darwin-arm64": "4.2.0", - "@rollup/rollup-darwin-x64": "4.2.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.2.0", - "@rollup/rollup-linux-arm64-gnu": "4.2.0", - "@rollup/rollup-linux-arm64-musl": "4.2.0", - "@rollup/rollup-linux-x64-gnu": "4.2.0", - "@rollup/rollup-linux-x64-musl": "4.2.0", - "@rollup/rollup-win32-arm64-msvc": "4.2.0", - "@rollup/rollup-win32-ia32-msvc": "4.2.0", - "@rollup/rollup-win32-x64-msvc": "4.2.0", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } } @@ -784,89 +849,123 @@ "integrity": "sha512-CH1qg/1DxRQ0HF/mvzFN/19+5txRSfI6HL+MqA1S+ZQk7NKVLChHRXJdWLfqg9d//lzLI4Vh24X/598iX6E1Xg==" }, "@rollup/rollup-android-arm-eabi": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.2.0.tgz", - "integrity": "sha512-8PlggAxGxavr+pkCNeV1TM2wTb2o+cUWDg9M1cm9nR27Dsn287uZtSLYXoQqQcmq+sYfF7lHfd3sWJJinH9GmA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "dev": true, "optional": true }, "@rollup/rollup-android-arm64": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.2.0.tgz", - "integrity": "sha512-+71T85hbMFrJI+zKQULNmSYBeIhru55PYoF/u75MyeN2FcxE4HSPw20319b+FcZ4lWx2Nx/Ql9tN+hoaD3GH/A==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "dev": true, "optional": true }, "@rollup/rollup-darwin-arm64": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.2.0.tgz", - "integrity": "sha512-IIIQLuG43QIElT1JZqUP/zqIdiJl4t9U/boa0GZnQTw9m1X0k3mlBuysbgYXeloLT1RozdL7bgw4lpSaI8GOXw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "dev": true, "optional": true }, "@rollup/rollup-darwin-x64": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.2.0.tgz", - "integrity": "sha512-BXcXvnLaea1Xz900omrGJhxHFJfH9jZ0CpJuVsbjjhpniJ6qiLXz3xA8Lekaa4MuhFcJd4f0r+Ky1G4VFbYhWw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "dev": true, "optional": true }, "@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.2.0.tgz", - "integrity": "sha512-f4K3MKw9Y4AKi4ANGnmPIglr+S+8tO858YrGVuqAHXxJdVghBmz9CPU9kDpOnGvT4g4vg5uNyIFpOOFvffXyMA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm-musleabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "dev": true, "optional": true }, "@rollup/rollup-linux-arm64-gnu": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.2.0.tgz", - "integrity": "sha512-bNsTYQBgp4H7w6cT7FZhesxpcUPahsSIy4NgdZjH1ZwEoZHxi4XKglj+CsSEkhsKi+x6toVvMylhjRKhEMYfnA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "dev": true, "optional": true }, "@rollup/rollup-linux-arm64-musl": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.2.0.tgz", - "integrity": "sha512-Jp1NxBJpGLuxRU2ihrQk4IZ+ia5nffobG6sOFUPW5PMYkF0kQtxEbeDuCa69Xif211vUOcxlOnf5IOEIpTEySA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-riscv64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-s390x-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", "dev": true, "optional": true }, "@rollup/rollup-linux-x64-gnu": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.2.0.tgz", - "integrity": "sha512-3p3iRtQmv2aXw+vtKNyZMLOQ+LSRsqArXjKAh2Oj9cqwfIRe7OXvdkOzWfZOIp1F/x5KJzVAxGxnniF4cMbnsQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "dev": true, "optional": true }, "@rollup/rollup-linux-x64-musl": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.2.0.tgz", - "integrity": "sha512-atih7IF/reUZe4LBLC5Izd44hth2tfDIG8LaPp4/cQXdHh9jabcZEvIeRPrpDq0i/Uu487Qu5gl5KwyAnWajnw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "dev": true, "optional": true }, "@rollup/rollup-win32-arm64-msvc": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.2.0.tgz", - "integrity": "sha512-vYxF3tKJeUE4ceYzpNe2p84RXk/fGK30I8frpRfv/MyPStej/mRlojztkN7Jtd1014HHVeq/tYaMBz/3IxkxZw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "dev": true, "optional": true }, "@rollup/rollup-win32-ia32-msvc": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.2.0.tgz", - "integrity": "sha512-1LZJ6zpl93SaPQvas618bMFarVwufWTaczH4ESAbFcwiC4OtznA6Ym+hFPyIGaJaGEB8uMWWac0uXGPXOg5FGA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "dev": true, "optional": true }, "@rollup/rollup-win32-x64-msvc": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.2.0.tgz", - "integrity": "sha512-dgQfFdHCNg08nM5zBmqxqc9vrm0DVzhWotpavbPa0j4//MAOKZEB75yGAfzQE9fUJ+4pvM1239Y4IhL8f6sSog==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "dev": true, "optional": true }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "esbuild": { "version": "0.19.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", @@ -905,23 +1004,28 @@ "optional": true }, "rollup": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.2.0.tgz", - "integrity": "sha512-deaMa9Z+jPVeBD2dKXv+h7EbdKte9++V2potc/ADqvVgEr6DEJ3ia9u0joarjC2lX/ubaCRYz3QVx0TzuVqAJA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, "requires": { - "@rollup/rollup-android-arm-eabi": "4.2.0", - "@rollup/rollup-android-arm64": "4.2.0", - "@rollup/rollup-darwin-arm64": "4.2.0", - "@rollup/rollup-darwin-x64": "4.2.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.2.0", - "@rollup/rollup-linux-arm64-gnu": "4.2.0", - "@rollup/rollup-linux-arm64-musl": "4.2.0", - "@rollup/rollup-linux-x64-gnu": "4.2.0", - "@rollup/rollup-linux-x64-musl": "4.2.0", - "@rollup/rollup-win32-arm64-msvc": "4.2.0", - "@rollup/rollup-win32-ia32-msvc": "4.2.0", - "@rollup/rollup-win32-x64-msvc": "4.2.0", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", + "@types/estree": "1.0.5", "fsevents": "~2.3.2" } } diff --git a/src/fable-library-py/fable_library/Async.fs b/src/fable-library-py/fable_library/Async.fs index 34a7cd8ed..4428a6d46 100644 --- a/src/fable-library-py/fable_library/Async.fs +++ b/src/fable-library-py/fable_library/Async.fs @@ -14,7 +14,7 @@ let defaultCancellationToken = new CancellationToken() [] type Async = static member StartWithContinuations - (computation: IAsync<'T>, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken) + (computation: Async<'T>, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken) : unit = let trampoline = Trampoline() @@ -31,7 +31,7 @@ type Async = } ) - static member StartWithContinuations(computation: IAsync<'T>, ?cancellationToken) : unit = + static member StartWithContinuations(computation: Async<'T>, ?cancellationToken) : unit = Async.StartWithContinuations( computation, emptyContinuation, @@ -44,8 +44,8 @@ type Async = Async.StartWithContinuations(computation, ?cancellationToken = cancellationToken) - static member StartImmediate(computation: IAsync<'T>, ?cancellationToken) = + static member StartImmediate(computation: Async<'T>, ?cancellationToken) = Async.Start(computation, ?cancellationToken = cancellationToken) -let startImmediate (computation: IAsync<'T>) = +let startImmediate (computation: Async<'T>) = Async.StartImmediate(computation, ?cancellationToken = None) diff --git a/src/fable-library-py/fable_library/AsyncBuilder.fs b/src/fable-library-py/fable_library/AsyncBuilder.fs index 8cc4151e6..85d39a979 100644 --- a/src/fable-library-py/fable_library/AsyncBuilder.fs +++ b/src/fable-library-py/fable_library/AsyncBuilder.fs @@ -74,9 +74,9 @@ type IAsyncContext<'T> = abstract member cancelToken: CancellationToken abstract member trampoline: Trampoline -type IAsync<'T> = IAsyncContext<'T> -> unit +type Async<'T> = IAsyncContext<'T> -> unit -let protectedCont<'T> (f: IAsync<'T>) = +let protectedCont<'T> (f: Async<'T>) = fun (ctx: IAsyncContext<'T>) -> if ctx.cancelToken.IsCancelled then ctx.onCancel (new OperationCanceledError()) @@ -93,7 +93,7 @@ let protectedCont<'T> (f: IAsync<'T>) = with err -> ctx.onError (err) -let protectedBind<'T, 'U> (computation: IAsync<'T>, binder: 'T -> IAsync<'U>) = +let protectedBind<'T, 'U> (computation: Async<'T>, binder: 'T -> Async<'U>) = protectedCont (fun (ctx: IAsyncContext<'U>) -> computation ( { new IAsyncContext<'T> with @@ -116,34 +116,32 @@ let protectedReturn<'T> (value: 'T) = protectedCont (fun (ctx: IAsyncContext<'T>) -> ctx.onSuccess (value)) type IAsyncBuilder = - abstract member Bind<'T, 'U> : IAsync<'T> * ('T -> IAsync<'U>) -> IAsync<'U> + abstract member Bind<'T, 'U> : Async<'T> * ('T -> Async<'U>) -> Async<'U> - abstract member Combine<'T> : IAsync * IAsync<'T> -> IAsync<'T> + abstract member Combine<'T> : Async * Async<'T> -> Async<'T> - abstract member Delay<'T> : (unit -> IAsync<'T>) -> IAsync<'T> + abstract member Delay<'T> : (unit -> Async<'T>) -> Async<'T> - //abstract member Return<'T> : [] values: 'T [] -> IAsync<'T> - abstract member Return<'T> : value: 'T -> IAsync<'T> + //abstract member Return<'T> : [] values: 'T [] -> Async<'T> + abstract member Return<'T> : value: 'T -> Async<'T> - abstract member While: (unit -> bool) * IAsync -> IAsync - abstract member Zero: unit -> IAsync + abstract member While: (unit -> bool) * Async -> Async + abstract member Zero: unit -> Async type AsyncBuilder() = interface IAsyncBuilder with - member this.Bind<'T, 'U>(computation: IAsync<'T>, binder: 'T -> IAsync<'U>) = - protectedBind (computation, binder) + member this.Bind<'T, 'U>(computation: Async<'T>, binder: 'T -> Async<'U>) = protectedBind (computation, binder) - member this.Combine<'T>(computation1: IAsync, computation2: IAsync<'T>) = + member this.Combine<'T>(computation1: Async, computation2: Async<'T>) = let self = this :> IAsyncBuilder self.Bind(computation1, (fun () -> computation2)) - member x.Delay<'T>(generator: unit -> IAsync<'T>) = + member x.Delay<'T>(generator: unit -> Async<'T>) = protectedCont (fun (ctx: IAsyncContext<'T>) -> generator () (ctx)) - - // public For(sequence: Iterable, body: (x: T) => IAsync) { + // public For(sequence: Iterable, body: (x: T) => Async) { // const iter = sequence[Symbol.iterator](); // let cur = iter.next(); // return this.While(() => !cur.done, this.Delay(() => { @@ -153,19 +151,19 @@ type AsyncBuilder() = // })); // } - member this.Return<'T>(value: 'T) : IAsync<'T> = protectedReturn (unbox value) - // member this.Return<'T>([] value: 'T []) : IAsync<'T> = + member this.Return<'T>(value: 'T) : Async<'T> = protectedReturn (unbox value) + // member this.Return<'T>([] value: 'T []) : Async<'T> = // match value with // | [||] -> protectedReturn (unbox null) // | [| value |] -> protectedReturn value // | _ -> failwith "Return takes zero or one argument." - // public ReturnFrom(computation: IAsync) { + // public ReturnFrom(computation: Async) { // return computation; // } - // public TryFinally(computation: IAsync, compensation: () => void) { + // public TryFinally(computation: Async, compensation: () => void) { // return protectedCont((ctx: IAsyncContext) => { // computation({ // onSuccess: (x: T) => { @@ -186,7 +184,7 @@ type AsyncBuilder() = // }); // } - // public TryWith(computation: IAsync, catchHandler: (e: any) => IAsync) { + // public TryWith(computation: Async, catchHandler: (e: any) => Async) { // return protectedCont((ctx: IAsyncContext) => { // computation({ // onSuccess: ctx.onSuccess, @@ -204,11 +202,11 @@ type AsyncBuilder() = // }); // } - // public Using(resource: T, binder: (x: T) => IAsync) { + // public Using(resource: T, binder: (x: T) => Async) { // return this.TryFinally(binder(resource), () => resource.Dispose()); // } - member this.While(guard: unit -> bool, computation: IAsync) : IAsync = + member this.While(guard: unit -> bool, computation: Async) : Async = let self = this :> IAsyncBuilder if guard () then @@ -216,8 +214,8 @@ type AsyncBuilder() = else self.Return() - // member this.Bind<'T, 'U>(computation: IAsync<'T>, binder: 'T -> IAsync<'U>) = (this :> IAsyncBuilder).Bind(computation, binder) - member this.Zero() : IAsync = + // member this.Bind<'T, 'U>(computation: Async<'T>, binder: 'T -> Async<'U>) = (this :> IAsyncBuilder).Bind(computation, binder) + member this.Zero() : Async = protectedCont (fun (ctx: IAsyncContext) -> ctx.onSuccess (())) // } diff --git a/src/fable-library-rust/Cargo.toml b/src/fable-library-rust/Cargo.toml index a1783daa5..0d56cbbfd 100644 --- a/src/fable-library-rust/Cargo.toml +++ b/src/fable-library-rust/Cargo.toml @@ -15,20 +15,21 @@ lrc_ptr = [] no_std = ["dep:hashbrown"] regexp = ["dep:regex"] static_do_bindings = ["dep:startup"] -threaded = ["atomic", "dep:futures"] +threaded = ["atomic", "dep:futures", "dep:futures-timer"] default = ["bigint", "datetime", "decimal", "enum_func", "enum_string", "guid", "regexp"] [dependencies] -startup = { version = "0.1", path = "vendored/startup", optional = true } +chrono = { version = "0.4", optional = true } +futures = { version = "0.3", features = ["executor", "thread-pool"], default-features = false, optional = true } +futures-timer = { version = "3.0", optional = true } hashbrown = { version = "0.14", optional = true } num-bigint = { version = "0.4", optional = true } num-integer = { version = "0.1", optional = true } num-traits = { version = "0.2", optional = true } -rust_decimal = { version = "1.35", features = ["maths"], default-features = false, optional = true } -futures = { version = "0.3", features = ["executor", "thread-pool"], optional = true } -uuid = { version = "1.10", features = ["v4"], default-features = false, optional = true } -chrono = { version = "0.4", optional = true } regex = { version = "1.10", optional = true } +rust_decimal = { version = "1.36", features = ["maths"], default-features = false, optional = true } +startup = { version = "0.1", path = "vendored/startup", optional = true } +uuid = { version = "1.10", features = ["v4"], default-features = false, optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/src/fable-library-rust/src/Array.fs b/src/fable-library-rust/src/Array.fs index 4023a0389..47faa53f4 100644 --- a/src/fable-library-rust/src/Array.fs +++ b/src/fable-library-rust/src/Array.fs @@ -467,41 +467,6 @@ let truncate (count: int) (source: 'T[]) : 'T[] = getSubArray source 0 count -// let addInPlace (x: 'T) (source: 'T[]) = -// // if isTypedArrayImpl source then invalidArg "array" "Typed arrays not supported" -// pushImpl source x |> ignore - -// let addRangeInPlace (range: seq<'T>) (source: 'T[]) = -// // if isTypedArrayImpl source then invalidArg "array" "Typed arrays not supported" -// for x in range do -// addInPlace x source - -// let insertRangeInPlace index (range: seq<'T>) (source: 'T[]) = -// // if isTypedArrayImpl source then invalidArg "array" "Typed arrays not supported" -// let mutable i = index -// for x in range do -// insertImpl source i x |> ignore -// i <- i + 1 - -// let removeInPlace (item: 'T) (source: 'T[]) = -// // if isTypedArrayImpl source then invalidArg "array" "Typed arrays not supported" -// let i = indexOfImpl source item 0 -// if i > -1 then -// spliceImpl source i 1 |> ignore -// true -// else -// false - -// let removeAllInPlace predicate (source: 'T[]) = -// let rec countRemoveAll count = -// let i = findIndexImpl predicate source -// if i > -1 then -// spliceImpl source i 1 |> ignore -// countRemoveAll count + 1 -// else -// count -// countRemoveAll 0 - // TODO: Check array lengths let copyTo (source: 'T[]) sourceIndex (target: 'T[]) targetIndex count = let diff = targetIndex - sourceIndex diff --git a/src/fable-library-rust/src/Async.rs b/src/fable-library-rust/src/Async.rs index 2babf7748..627a0f77f 100644 --- a/src/fable-library-rust/src/Async.rs +++ b/src/fable-library-rust/src/Async.rs @@ -9,6 +9,7 @@ pub mod Async_ { use futures::executor::{self, LocalPool}; use futures::lock::Mutex; use futures::FutureExt; + use futures_timer::Delay; use super::Task_::Task; @@ -38,6 +39,14 @@ pub mod Async_ { } } + pub fn sleep(milliseconds: i32) -> Arc> { + let fut = Delay::new(Duration::from_millis(milliseconds as u64)); + let a: Pin + Send + Sync + 'static>> = Box::pin(fut); + Arc::from(Async { + future: Arc::from(Mutex::from(a)), + }) + } + pub fn startAsTask(a: Arc>) -> Arc> { let unitFut = async move { let mut res = a.future.lock().await; diff --git a/src/fable-library-rust/src/FSharp.Collections.fs b/src/fable-library-rust/src/FSharp.Collections.fs new file mode 100644 index 000000000..1a5573fd5 --- /dev/null +++ b/src/fable-library-rust/src/FSharp.Collections.fs @@ -0,0 +1,21 @@ +namespace FSharp.Collections + +open System.Collections.Generic + +module HashIdentity = + let FromFunctions<'T> hasher equals : IEqualityComparer<'T> = + EqualityComparer<'T>.Create(equals, hasher) + + let Structural<'T when 'T: equality> : IEqualityComparer<'T> = + EqualityComparer<'T> + .Create(LanguagePrimitives.GenericEquality, LanguagePrimitives.GenericHash) + + let Reference<'T when 'T: not struct> : IEqualityComparer<'T> = + EqualityComparer<'T> + .Create(LanguagePrimitives.PhysicalEquality, LanguagePrimitives.PhysicalHash) + +module ComparisonIdentity = + let FromFunction<'T> comparer : IComparer<'T> = Comparer<'T>.Create(comparer) + + let Structural<'T when 'T: comparison> : IComparer<'T> = + Comparer<'T>.Create(LanguagePrimitives.GenericComparison) diff --git a/src/fable-library-rust/src/Fable.Library.Rust.fsproj b/src/fable-library-rust/src/Fable.Library.Rust.fsproj index 69e1d13ab..fb90c45f4 100644 --- a/src/fable-library-rust/src/Fable.Library.Rust.fsproj +++ b/src/fable-library-rust/src/Fable.Library.Rust.fsproj @@ -18,6 +18,7 @@ + diff --git a/src/fable-library-rust/src/HashMap.rs b/src/fable-library-rust/src/HashMap.rs index a1bc5d230..9fc3a0686 100644 --- a/src/fable-library-rust/src/HashMap.rs +++ b/src/fable-library-rust/src/HashMap.rs @@ -9,9 +9,10 @@ pub mod HashMap_ { #[cfg(not(feature = "no_std"))] use std::collections; - use crate::Interfaces_::System::Collections::Generic::IEqualityComparer_1; use crate::NativeArray_::{array_from, Array}; use crate::Native_::{mkRefMut, seq_to_iter, HashKey, Lrc, LrcPtr, MutCell, Seq, Vec}; + use crate::Interfaces_::System::Collections::Generic::EqualityComparer_1; + use crate::Interfaces_::System::Collections::Generic::IEqualityComparer_1; use core::fmt::{Debug, Display, Formatter, Result}; use core::hash::{Hash, Hasher}; @@ -21,10 +22,13 @@ pub mod HashMap_ { #[derive(Clone)] //, Debug, Default, PartialEq, PartialOrd, Eq, Hash, Ord)] pub struct HashMap { hash_map: Lrc>, - comparer: Option>>, + comparer: LrcPtr>, } - impl Default for HashMap { + impl Default for HashMap + where + K: Clone + Hash + PartialEq + 'static, + { fn default() -> HashMap { new_empty() } @@ -49,13 +53,10 @@ pub mod HashMap_ { } } - fn from_iter>( + fn from_iter>( iter: I, - comparer: Option>>, - ) -> HashMap - where - K: Clone + Hash + PartialEq + 'static, - { + comparer: LrcPtr>, + ) -> HashMap { let it = iter.map(|(k, v)| { let key = HashKey::new(k, comparer.clone()); (key, v) @@ -70,17 +71,23 @@ pub mod HashMap_ { map.iter().map(|(k, v)| (k.key.clone(), v.clone())) } - pub fn new_empty() -> HashMap { + pub fn new_empty() -> HashMap + where + K: Clone + Hash + PartialEq + 'static, + { HashMap { hash_map: mkRefMut(collections::HashMap::new()), - comparer: None, + comparer: EqualityComparer_1::::get_Default(), } } - pub fn new_with_capacity(capacity: i32) -> HashMap { + pub fn new_with_capacity(capacity: i32) -> HashMap + where + K: Clone + Hash + PartialEq + 'static, + { HashMap { hash_map: mkRefMut(collections::HashMap::with_capacity(capacity as usize)), - comparer: None, + comparer: EqualityComparer_1::::get_Default(), } } @@ -89,7 +96,7 @@ pub mod HashMap_ { ) -> HashMap { HashMap { hash_map: mkRefMut(collections::HashMap::new()), - comparer: Some(comparer), + comparer, } } @@ -99,7 +106,7 @@ pub mod HashMap_ { ) -> HashMap { HashMap { hash_map: mkRefMut(collections::HashMap::with_capacity(capacity as usize)), - comparer: Some(comparer), + comparer, } } @@ -107,34 +114,25 @@ pub mod HashMap_ { where K: Clone + Hash + PartialEq + 'static, { - from_iter(seq_to_iter(&seq), None) + from_iter(seq_to_iter(&seq), EqualityComparer_1::::get_Default()) } - pub fn new_from_enumerable_comparer( + pub fn new_from_enumerable_comparer( seq: Seq<(K, V)>, comparer: LrcPtr>, - ) -> HashMap - where - K: Clone + Hash + PartialEq + 'static, - { - from_iter(seq_to_iter(&seq), Some(comparer)) + ) -> HashMap { + from_iter(seq_to_iter(&seq), comparer) } - pub fn new_from_dictionary(map: HashMap) -> HashMap - where - K: Clone + Hash + PartialEq + 'static, - { - from_iter(to_iter(&map), None) + pub fn new_from_dictionary(map: HashMap) -> HashMap { + from_iter(to_iter(&map), map.comparer.clone()) } - pub fn new_from_dictionary_comparer( + pub fn new_from_dictionary_comparer( map: HashMap, comparer: LrcPtr>, - ) -> HashMap - where - K: Clone + Hash + PartialEq + 'static, - { - from_iter(to_iter(&map), Some(comparer)) + ) -> HashMap { + from_iter(to_iter(&map), comparer) } pub fn new_from_tuple_array(a: Array>) -> HashMap @@ -142,7 +140,7 @@ pub mod HashMap_ { K: Clone + Hash + PartialEq + 'static, { let it = a.iter().map(|tup| tup.as_ref().clone()); - from_iter(it, None) + from_iter(it, EqualityComparer_1::::get_Default()) } pub fn isReadOnly(map: HashMap) -> bool { @@ -153,10 +151,7 @@ pub mod HashMap_ { map.len() as i32 } - pub fn containsKey(map: HashMap, k: K) -> bool - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn containsKey(map: HashMap, k: K) -> bool { let key = HashKey::new(k, map.comparer.clone()); map.contains_key(&key) } @@ -165,10 +160,7 @@ pub mod HashMap_ { map.values().any(|x| x.eq(&v)) } - pub fn tryAdd(map: HashMap, k: K, v: V) -> bool - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn tryAdd(map: HashMap, k: K, v: V) -> bool { let key = HashKey::new(k, map.comparer.clone()); // map.get_mut().try_insert(key, v).is_ok() // nightly only if map.contains_key(&key) { @@ -178,10 +170,7 @@ pub mod HashMap_ { } } - pub fn add(map: HashMap, k: K, v: V) - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn add(map: HashMap, k: K, v: V) { let key = HashKey::new(k, map.comparer.clone()); match map.get_mut().insert(key, v) { Some(v) => { @@ -191,10 +180,7 @@ pub mod HashMap_ { } } - pub fn remove(map: HashMap, k: K) -> bool - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn remove(map: HashMap, k: K) -> bool { let key = HashKey::new(k, map.comparer.clone()); map.get_mut().remove(&key).is_some() } @@ -203,10 +189,7 @@ pub mod HashMap_ { map.get_mut().clear(); } - pub fn get(map: HashMap, k: K) -> V - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn get(map: HashMap, k: K) -> V { let key = HashKey::new(k, map.comparer.clone()); match map.get_mut().get(&key) { Some(v) => v.clone(), @@ -216,18 +199,16 @@ pub mod HashMap_ { } } - pub fn set(map: HashMap, k: K, v: V) - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn set(map: HashMap, k: K, v: V) { let key = HashKey::new(k, map.comparer.clone()); map.get_mut().insert(key, v); // ignore return value } - pub fn tryGetValue(map: HashMap, k: K, res: &MutCell) -> bool - where - K: Clone + Hash + PartialEq + 'static, - { + pub fn tryGetValue( + map: HashMap, + k: K, + res: &MutCell, + ) -> bool { let key = HashKey::new(k, map.comparer.clone()); match map.get_mut().get(&key) { Some(v) => { diff --git a/src/fable-library-rust/src/HashSet.rs b/src/fable-library-rust/src/HashSet.rs index 91694c28b..dfde58543 100644 --- a/src/fable-library-rust/src/HashSet.rs +++ b/src/fable-library-rust/src/HashSet.rs @@ -9,9 +9,10 @@ pub mod HashSet_ { #[cfg(not(feature = "no_std"))] use std::collections; - use crate::Interfaces_::System::Collections::Generic::IEqualityComparer_1; use crate::NativeArray_::{array_from, Array}; use crate::Native_::{mkRefMut, seq_to_iter, HashKey, Lrc, LrcPtr, MutCell, Seq, Vec}; + use crate::Interfaces_::System::Collections::Generic::EqualityComparer_1; + use crate::Interfaces_::System::Collections::Generic::IEqualityComparer_1; use core::fmt::{Debug, Display, Formatter, Result}; use core::hash::Hash; @@ -21,10 +22,13 @@ pub mod HashSet_ { #[derive(Clone)] //, Debug, Default, PartialEq, PartialOrd, Eq, Hash, Ord)] pub struct HashSet { hash_set: Lrc>, - comparer: Option>>, + comparer: LrcPtr>, } - impl Default for HashSet { + impl Default for HashSet + where + T: Clone + Hash + PartialEq + 'static, + { fn default() -> HashSet { new_empty() } @@ -49,17 +53,14 @@ pub mod HashSet_ { } } - fn from_iter>( + fn from_iter>( iter: I, - comparer: Option>>, - ) -> HashSet - where - T: Clone + Hash + PartialEq + 'static, - { + comparer: LrcPtr>, + ) -> HashSet { let it = iter.map(|v| HashKey::new(v, comparer.clone())); HashSet { hash_set: mkRefMut(collections::HashSet::from_iter(it)), - comparer: comparer.clone(), + comparer, } } @@ -67,24 +68,30 @@ pub mod HashSet_ { set.iter().map(|k| k.key.clone()) } - pub fn new_empty() -> HashSet { + pub fn new_empty() -> HashSet + where + T: Clone + Hash + PartialEq + 'static, + { HashSet { hash_set: mkRefMut(collections::HashSet::new()), - comparer: None, + comparer: EqualityComparer_1::::get_Default(), } } - pub fn new_with_capacity(capacity: i32) -> HashSet { + pub fn new_with_capacity(capacity: i32) -> HashSet + where + T: Clone + Hash + PartialEq + 'static, + { HashSet { hash_set: mkRefMut(collections::HashSet::with_capacity(capacity as usize)), - comparer: None, + comparer: EqualityComparer_1::::get_Default(), } } pub fn new_with_comparer(comparer: LrcPtr>) -> HashSet { HashSet { hash_set: mkRefMut(collections::HashSet::new()), - comparer: Some(comparer), + comparer, } } @@ -94,7 +101,7 @@ pub mod HashSet_ { ) -> HashSet { HashSet { hash_set: mkRefMut(collections::HashSet::with_capacity(capacity as usize)), - comparer: Some(comparer), + comparer, } } @@ -102,7 +109,7 @@ pub mod HashSet_ { where T: Clone + Hash + PartialEq + 'static, { - from_iter(seq_to_iter(&seq), None) + from_iter(seq_to_iter(&seq), EqualityComparer_1::::get_Default()) } pub fn new_from_array(a: Array) -> HashSet { @@ -112,14 +119,11 @@ pub mod HashSet_ { } } - pub fn new_from_enumerable_comparer( + pub fn new_from_enumerable_comparer( seq: Seq, comparer: LrcPtr>, - ) -> HashSet - where - T: Clone + Hash + PartialEq + 'static, - { - from_iter(seq_to_iter(&seq), Some(comparer)) + ) -> HashSet { + from_iter(seq_to_iter(&seq), comparer) } pub fn isReadOnly(set: HashSet) -> bool { @@ -130,26 +134,17 @@ pub mod HashSet_ { set.len() as i32 } - pub fn contains(set: HashSet, v: T) -> bool - where - T: Clone + Hash + PartialEq + 'static, - { + pub fn contains(set: HashSet, v: T) -> bool { let key = HashKey::new(v, set.comparer.clone()); set.contains(&key) } - pub fn add(set: HashSet, v: T) -> bool - where - T: Clone + Hash + PartialEq + 'static, - { + pub fn add(set: HashSet, v: T) -> bool { let key = HashKey::new(v, set.comparer.clone()); set.get_mut().insert(key) } - pub fn remove(set: HashSet, v: T) -> bool - where - T: Clone + Hash + PartialEq + 'static, - { + pub fn remove(set: HashSet, v: T) -> bool { let key = HashKey::new(v, set.comparer.clone()); set.get_mut().remove(&key) } diff --git a/src/fable-library-rust/src/Interop.rs b/src/fable-library-rust/src/Interop.rs index 541cef43d..c1c5bf469 100644 --- a/src/fable-library-rust/src/Interop.rs +++ b/src/fable-library-rust/src/Interop.rs @@ -63,7 +63,7 @@ pub mod ListExt { } pub mod SetExt { - use crate::Native_::{makeCompare, seq_to_iter, Func2, Vec}; + use crate::Native_::{make_compare, seq_to_iter, Func2, Vec}; use crate::Set_::{add, compareTo, empty, equals, toSeq, Set}; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; @@ -98,13 +98,13 @@ pub mod SetExt { impl PartialOrd for Set { fn partial_cmp(&self, other: &Self) -> Option { - Some(makeCompare(Func2::from(compareTo))(self, other)) + Some(make_compare(Func2::from(compareTo))(self, other)) } } impl Ord for Set { fn cmp(&self, other: &Self) -> Ordering { - makeCompare(Func2::from(compareTo))(self, other) + make_compare(Func2::from(compareTo))(self, other) } } @@ -147,7 +147,7 @@ pub mod SetExt { pub mod MapExt { use crate::Map_::{add, compareTo, empty, equals, iterate, toSeq, Map}; - use crate::Native_::{makeCompare, seq_to_iter, Func2, Vec}; + use crate::Native_::{make_compare, seq_to_iter, Func2, Vec}; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; @@ -181,13 +181,13 @@ pub mod MapExt { impl PartialOrd for Map { fn partial_cmp(&self, other: &Self) -> Option { - Some(makeCompare(Func2::from(compareTo))(self, other)) + Some(make_compare(Func2::from(compareTo))(self, other)) } } impl Ord for Map { fn cmp(&self, other: &Self) -> Ordering { - makeCompare(Func2::from(compareTo))(self, other) + make_compare(Func2::from(compareTo))(self, other) } } diff --git a/src/fable-library-rust/src/Native.rs b/src/fable-library-rust/src/Native.rs index 75ced0b2e..a0d6d6efb 100644 --- a/src/fable-library-rust/src/Native.rs +++ b/src/fable-library-rust/src/Native.rs @@ -131,7 +131,16 @@ pub mod Native_ { } } - pub fn makeCompare( + pub fn partial_compare(x: &T, y: &T) -> Ordering { + match x.partial_cmp(y) { + Some(ordering) => ordering, + None if y == y => Ordering::Less, // y is not NaN + None if x == x => Ordering::Greater, // x is not NaN + None => Ordering::Equal, + } + } + + pub fn make_compare( comparer: Func2, ) -> impl Fn(&T, &T) -> Ordering { move |x, y| match comparer(x.clone(), y.clone()) { @@ -148,11 +157,11 @@ pub mod Native_ { #[derive(Clone)] pub struct HashKey { pub key: T, - pub comparer: Option>>, + pub comparer: LrcPtr>, } impl HashKey { - pub fn new(key: T, comparer: Option>>) -> HashKey { + pub fn new(key: T, comparer: LrcPtr>) -> HashKey { HashKey { key, comparer } } } @@ -169,27 +178,21 @@ pub mod Native_ { } } - impl Hash for HashKey { + impl Hash for HashKey { #[inline] fn hash(&self, state: &mut H) { - match &self.comparer { - Some(comp) => comp.GetHashCode(self.key.clone()).hash(state), - None => self.key.hash(state), - } + self.comparer.GetHashCode(self.key.clone()).hash(state) } } - impl PartialEq for HashKey { + impl PartialEq for HashKey { #[inline] fn eq(&self, other: &Self) -> bool { - match &self.comparer { - Some(comp) => comp.Equals(self.key.clone(), other.key.clone()), - None => self.key.eq(&other.key), - } + self.comparer.Equals(self.key.clone(), other.key.clone()) } } - impl Eq for HashKey {} + impl Eq for HashKey {} // ----------------------------------------------------------- // Type testing diff --git a/src/fable-library-rust/src/NativeArray.rs b/src/fable-library-rust/src/NativeArray.rs index 9c3c80baf..9faec9b9d 100644 --- a/src/fable-library-rust/src/NativeArray.rs +++ b/src/fable-library-rust/src/NativeArray.rs @@ -1,5 +1,8 @@ pub mod NativeArray_ { - use crate::Native_::{alloc, mkRefMut, Lrc, LrcPtr, MutCell, Vec}; + use crate::Global_::SR::indexOutOfBounds; + use crate::Native_::{alloc, make_compare, mkRefMut, partial_compare, seq_to_iter}; + use crate::Native_::{Func1, Func2, Lrc, LrcPtr, MutCell, Seq, Vec}; + use crate::System::Collections::Generic::IComparer_1; // ----------------------------------------------------------- // Arrays @@ -39,7 +42,7 @@ pub mod NativeArray_ { impl Into> for Array { fn into(self) -> Vec { - self.get().iter().map(|item| item.clone()).collect() + self.get().iter().cloned().collect() } } @@ -51,6 +54,10 @@ pub mod NativeArray_ { array_from(a.to_vec()) } + pub fn new_init(value: &T, count: i32) -> Array { + array_from(alloc::vec![value.clone(); count as usize]) + } + pub fn new_empty() -> Array { array_from(Vec::new()) } @@ -59,35 +66,312 @@ pub mod NativeArray_ { array_from(Vec::with_capacity(capacity as usize)) } - pub fn new_init(value: &T, count: i32) -> Array { - array_from(alloc::vec![value.clone(); count as usize]) + pub fn new_from_enumerable(seq: Seq) -> Array { + array_from(Vec::from_iter(seq_to_iter(&seq))) } - pub fn new_copy(a: Array) -> Array { - array_from(a.to_vec()) + pub fn get_Capacity(a: Array) -> i32 { + a.capacity() as i32 + } + + pub fn get_Count(a: Array) -> i32 { + a.len() as i32 } pub fn isReadOnly(a: Array) -> bool { false } - pub fn count(a: Array) -> i32 { - a.len() as i32 + pub fn add(a: Array, v: T) { + a.get_mut().push(v); } - pub fn contains(a: Array, v: T) -> bool { - a.contains(&v) + pub fn addRange(a: Array, seq: Seq) { + let range = a.len()..a.len(); + a.get_mut().splice(range, seq_to_iter(&seq)); } - pub fn add(a: Array, v: T) { - a.get_mut().push(v); + pub fn copyTo(src: Array, dest: Array) { + copyTo2(src, dest, 0) + } + + pub fn copyTo2(src: Array, dest: Array, destIndex: i32) { + let count = src.len() as i32; + copyTo4(src, 0, dest, destIndex, count) + } + + pub fn copyTo4( + src: Array, + srcIndex: i32, + dest: Array, + destIndex: i32, + count: i32, + ) { + let check1 = srcIndex + count > src.len() as i32; + let check2 = destIndex + count > dest.len() as i32; + if srcIndex < 0 || destIndex < 0 || count < 0 || check1 || check2 { + panic!("{}", indexOutOfBounds()); + } + let rangeFrom = srcIndex as usize..(srcIndex + count) as usize; + let rangeTo = destIndex as usize..(destIndex + count) as usize; + dest.get_mut()[rangeTo].clone_from_slice(&src.as_slice()[rangeFrom]); } - pub fn remove(a: Array, pos: i32) -> bool { - a.get_mut().remove(pos as usize); true + pub fn contains(a: Array, v: T) -> bool { + a.contains(&v) } pub fn clear(a: Array) { a.get_mut().clear(); } + + pub fn convertAll( + a: Array, + converter: Func1, + ) -> Array { + let it = a.iter().map(|x| converter(x.clone())); + array_from(it.collect()) + } + + pub fn binarySearch(a: Array, v: T) -> i32 { + let res = a.binary_search_by(|x| partial_compare(x, &v)); + match res { + Ok(i) => i as i32, + Err(i) => !i as i32, + } + } + + pub fn binarySearch2( + a: Array, + v: T, + comparer: LrcPtr>, + ) -> i32 { + let cmp = make_compare(Func2::new(move |x: T, y: T| comparer.Compare(x, y))); + let res = a.binary_search_by(|x| cmp(x, &v)); + match res { + Ok(i) => i as i32, + Err(i) => !i as i32, + } + } + + pub fn binarySearch4( + a: Array, + index: i32, + count: i32, + v: T, + comparer: LrcPtr>, + ) -> i32 { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + count > len { + panic!("{}", indexOutOfBounds()); + } + let range = index as usize..(index + count) as usize; + let cmp = make_compare(Func2::new(move |x: T, y: T| comparer.Compare(x, y))); + let res = a.as_slice()[range].binary_search_by(|x| cmp(x, &v)); + match res { + Ok(i) => (index as usize + i) as i32, + Err(i) => !(index as usize + i) as i32, + } + } + + pub fn exists(a: Array, predicate: Func1) -> bool { + a.iter().find(|&x| predicate(x.clone())).is_some() + } + + pub fn getRange(a: Array, index: i32, count: i32) -> Array { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + count > len { + panic!("{}", indexOutOfBounds()); + } + let range = index as usize..(index + count) as usize; + array_from(a.as_slice()[range].to_vec()) + } + + pub fn forEach(a: Array, action: Func1) { + a.iter().for_each(|x| action(x.clone())); + } + + pub fn findAll(a: Array, predicate: Func1) -> Array { + let it = a.iter().filter(|&x| predicate(x.clone())); + array_from(it.cloned().collect()) + } + + pub fn find(a: Array, predicate: Func1) -> T { + let pos = a.iter().position(|x| predicate(x.clone())); + match pos { + Some(index) => a[index as i32].clone(), + None => T::default(), + } + } + + pub fn findLast(a: Array, predicate: Func1) -> T { + let pos = a.iter().rposition(|x| predicate(x.clone())); + match pos { + Some(index) => a[index as i32].clone(), + None => T::default(), + } + } + + pub fn findIndex(a: Array, predicate: Func1) -> i32 { + let mut it = a.iter(); + unwrap_pos(it.position(|x| predicate(x.clone()))) + } + + pub fn findLastIndex(a: Array, predicate: Func1) -> i32 { + let mut it = a.iter(); + unwrap_pos(it.rposition(|x| predicate(x.clone()))) + } + + fn unwrap_pos(pos: Option) -> i32 { + match pos { + Some(index) => index as i32, + None => -1, + } + } + + pub fn indexOf(a: Array, v: T) -> i32 { + let mut it = a.iter(); + unwrap_pos(it.position(|x| x.eq(&v))) + } + + pub fn indexOf2(a: Array, v: T, index: i32) -> i32 { + let len = a.len() as i32; + if index < 0 || index >= len { + panic!("{}", indexOutOfBounds()); + } + let mut it = a.iter().skip(index as usize); + unwrap_pos(it.position(|x| x.eq(&v)).map(|i| i + index as usize)) + } + + pub fn indexOf3(a: Array, v: T, index: i32, count: i32) -> i32 { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + count > len { + panic!("{}", indexOutOfBounds()); + } + let mut it = a.iter().skip(index as usize).take(count as usize); + unwrap_pos(it.position(|x| x.eq(&v)).map(|i| i + index as usize)) + } + + pub fn lastIndexOf(a: Array, v: T) -> i32 { + let mut it = a.iter(); + unwrap_pos(it.rposition(|x| x.eq(&v))) + } + + pub fn lastIndexOf2(a: Array, v: T, index: i32) -> i32 { + lastIndexOf3(a, v, index, index + 1) + } + + pub fn lastIndexOf3(a: Array, v: T, index: i32, count: i32) -> i32 { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + 1 < count { + panic!("{}", indexOutOfBounds()); + } + let start = index as usize + 1 - count as usize; + let mut it = a.iter().skip(start).take(count as usize); + unwrap_pos(it.rposition(|x| x.eq(&v)).map(|i| i + start)) + } + + pub fn insert(a: Array, pos: i32, v: T) { + a.get_mut().insert(pos as usize, v); + } + + pub fn insertRange(a: Array, index: i32, seq: Seq) { + let len = a.len() as i32; + if index < 0 || index >= len { + panic!("{}", indexOutOfBounds()); + } + let range = index as usize..index as usize; + a.get_mut().splice(range, seq_to_iter(&seq)); + } + + pub fn remove(a: Array, v: T) -> bool { + let pos = a.iter().position(|x| x.eq(&v)); + match pos { + Some(index) => { + a.get_mut().remove(index); + true + } + None => false, + } + } + + pub fn removeAt(a: Array, index: i32) { + let len = a.len() as i32; + if index < 0 || index >= len { + panic!("{}", indexOutOfBounds()); + } + a.get_mut().remove(index as usize); + } + + pub fn removeRange(a: Array, index: i32, count: i32) { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + count > len { + panic!("{}", indexOutOfBounds()); + } + let range = index as usize..(index + count) as usize; + a.get_mut().splice(range, core::iter::empty::()); + } + + pub fn removeAll(a: Array, predicate: Func1) -> i32 { + let old_len = a.len(); + a.get_mut().retain(|x| !predicate(x.clone())); + (old_len - a.len()) as i32 + } + + pub fn reverse(a: Array) { + a.get_mut().reverse(); + } + + pub fn reverse2(a: Array, index: i32, count: i32) { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + count > len { + panic!("{}", indexOutOfBounds()); + } + let range = index as usize..(index + count) as usize; + a.get_mut()[range].reverse(); + } + + pub fn slice(a: Array, index: i32, count: i32) -> Array { + getRange(a, index, count) + } + + pub fn sort(a: Array) { + a.get_mut().sort_by(partial_compare); + } + + pub fn sortBy(a: Array, comparer: Func2) { + a.get_mut().sort_by(make_compare(comparer)); + } + + pub fn sortWith(a: Array, comparer: LrcPtr>) { + let cmp = Func2::new(move |x: T, y: T| comparer.Compare(x, y)); + a.get_mut().sort_by(make_compare(cmp)); + } + + pub fn sortWith2( + a: Array, + index: i32, + count: i32, + comparer: LrcPtr>, + ) { + let len = a.len() as i32; + if index < 0 || index >= len || count < 0 || index + count > len { + panic!("{}", indexOutOfBounds()); + } + let range = index as usize..(index + count) as usize; + let cmp = Func2::new(move |x: T, y: T| comparer.Compare(x, y)); + a.get_mut()[range].sort_by(make_compare(cmp)); + } + + pub fn toArray(a: Array) -> Array { + array_from(a.to_vec()) + } + + pub fn trimExcess(a: Array) { + a.get_mut().shrink_to_fit(); + } + + pub fn trueForAll(a: Array, predicate: Func1) -> bool { + a.iter().all(|x| predicate(x.clone())) + } } diff --git a/src/fable-library-rust/src/System.Collections.Generic.fs b/src/fable-library-rust/src/System.Collections.Generic.fs index 34f091306..d33fcedd5 100644 --- a/src/fable-library-rust/src/System.Collections.Generic.fs +++ b/src/fable-library-rust/src/System.Collections.Generic.fs @@ -2,9 +2,10 @@ namespace System.Collections.Generic open Global_ -type Comparer<'T when 'T: comparison>(comparison: 'T -> 'T -> int) = +type Comparer<'T>(comparison: 'T -> 'T -> int) = - static member Default = Comparer<'T>(LanguagePrimitives.GenericComparison) + static member get_Default<'V when 'V: comparison>() = + Comparer<'V>(LanguagePrimitives.GenericComparison) static member Create(comparison) = Comparer<'T>(comparison) @@ -13,10 +14,10 @@ type Comparer<'T when 'T: comparison>(comparison: 'T -> 'T -> int) = interface IComparer<'T> with member _.Compare(x, y) = comparison x y -type EqualityComparer<'T when 'T: equality>(equals: 'T -> 'T -> bool, getHashCode: 'T -> int) = +type EqualityComparer<'T>(equals: 'T -> 'T -> bool, getHashCode: 'T -> int) = - static member Default = - EqualityComparer<'T>(LanguagePrimitives.GenericEquality, LanguagePrimitives.GenericHash) + static member get_Default<'V when 'V: equality>() = + EqualityComparer<'V>(LanguagePrimitives.GenericEquality, LanguagePrimitives.GenericHash) static member Create(equals, getHashCode) = EqualityComparer<'T>(equals, getHashCode) diff --git a/src/fable-library-ts/Async.ts b/src/fable-library-ts/Async.ts index 4c2577db4..013735fc7 100644 --- a/src/fable-library-ts/Async.ts +++ b/src/fable-library-ts/Async.ts @@ -1,40 +1,33 @@ import { OperationCanceledError, Trampoline } from "./AsyncBuilder.js"; import { Continuation, Continuations } from "./AsyncBuilder.js"; -import { CancellationToken } from "./AsyncBuilder.js"; -import { IAsync } from "./AsyncBuilder.js"; -import { IAsyncContext } from "./AsyncBuilder.js"; -import { protectedCont } from "./AsyncBuilder.js"; -import { protectedBind } from "./AsyncBuilder.js"; -import { protectedReturn } from "./AsyncBuilder.js"; +import { Async, IAsyncContext, CancellationToken } from "./AsyncBuilder.js"; +import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.js"; import { FSharpChoice$2_$union, Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.js"; import { TimeoutException } from "./SystemException.js"; -// Implemented just for type references -export class Async<_T> { } - function emptyContinuation(_x: T) { // NOP } // see AsyncBuilder.Delay -function delay(generator: () => IAsync) { +function delay(generator: () => Async) { return protectedCont((ctx: IAsyncContext) => generator()(ctx)); } // MakeAsync: body:(AsyncActivation<'T> -> AsyncReturn) -> Async<'T> -export function makeAsync(body: IAsync) { +export function makeAsync(body: Async) { return body; } // Invoke: computation: Async<'T> -> ctxt:AsyncActivation<'T> -> AsyncReturn -export function invoke(computation: IAsync, ctx: IAsyncContext) { +export function invoke(computation: Async, ctx: IAsyncContext) { return computation(ctx); } // CallThenInvoke: ctxt:AsyncActivation<'T> -> result1:'U -> part2:('U -> Async<'T>) -> AsyncReturn -export function callThenInvoke(ctx: IAsyncContext, result1: U, part2: (x: U) => IAsync) { +export function callThenInvoke(ctx: IAsyncContext, result1: U, part2: (x: U) => Async) { return part2(result1)(ctx); } // Bind: ctxt:AsyncActivation<'T> -> part1:Async<'U> -> part2:('U -> Async<'T>) -> AsyncReturn -export function bind(ctx: IAsyncContext, part1: IAsync, part2: (x: U) => IAsync) { +export function bind(ctx: IAsyncContext, part1: Async, part2: (x: U) => Async) { return protectedBind(part1, part2)(ctx); } @@ -64,7 +57,7 @@ export function throwIfCancellationRequested(token: CancellationToken) { } } -function throwAfter(millisecondsDueTime: number) : IAsync { +function throwAfter(millisecondsDueTime: number): Async { return protectedCont((ctx: IAsyncContext) => { let tokenId: number; const timeoutId = setTimeout(() => { @@ -78,7 +71,7 @@ function throwAfter(millisecondsDueTime: number) : IAsync { }); } -export function startChild(computation: IAsync, ms?: number): IAsync> { +export function startChild(computation: Async, ms?: number): Async> { if (ms) { const computationWithTimeout = protectedBind( parallel2( @@ -110,7 +103,7 @@ export function cancellationToken() { export const defaultCancellationToken = new CancellationToken(); -export function catchAsync(work: IAsync) { +export function catchAsync(work: Async) { return protectedCont((ctx: IAsyncContext>) => { work({ onSuccess: (x) => ctx.onSuccess(Choice_makeChoice1Of2(x)), @@ -127,21 +120,21 @@ export function fromContinuations(f: (conts: Continuations) => void) { f([ctx.onSuccess, ctx.onError, ctx.onCancel])); } -export function ignore(computation: IAsync) { +export function ignore(computation: Async) { return protectedBind(computation, (_x) => protectedReturn(void 0)); } -export function parallel(computations: Iterable>) { +export function parallel(computations: Iterable>) { return delay(() => awaitPromise(Promise.all(Array.from(computations, (w) => startAsPromise(w))))); } -function parallel2(a: IAsync, b: IAsync): IAsync<[T, U]> { - return delay(() => awaitPromise(Promise.all([ startAsPromise(a), startAsPromise(b) ]))); +function parallel2(a: Async, b: Async): Async<[T, U]> { + return delay(() => awaitPromise(Promise.all([startAsPromise(a), startAsPromise(b)]))); } -export function sequential(computations: Iterable>) { +export function sequential(computations: Iterable>) { - function _sequential(computations: Iterable>): Promise { + function _sequential(computations: Iterable>): Promise { let pr: Promise = Promise.resolve([]); for (const c of computations) { pr = pr.then(results => startAsPromise(c).then(r => results.concat([r]))) @@ -170,16 +163,16 @@ export function runSynchronously(): never { throw new Error("Asynchronous code cannot be run synchronously in JS"); } -export function start(computation: IAsync, cancellationToken?: CancellationToken) { +export function start(computation: Async, cancellationToken?: CancellationToken) { return startWithContinuations(computation, cancellationToken); } -export function startImmediate(computation: IAsync, cancellationToken?: CancellationToken) { +export function startImmediate(computation: Async, cancellationToken?: CancellationToken) { return start(computation, cancellationToken); } export function startWithContinuations( - computation: IAsync, + computation: Async, continuation?: Continuation | CancellationToken, exceptionContinuation?: Continuation, cancellationContinuation?: Continuation, @@ -198,10 +191,8 @@ export function startWithContinuations( }); } -export function startAsPromise(computation: IAsync, cancellationToken?: CancellationToken) { +export function startAsPromise(computation: Async, cancellationToken?: CancellationToken) { return new Promise((resolve: Continuation, reject: Continuation) => startWithContinuations(computation, resolve, reject, reject, cancellationToken ? cancellationToken : defaultCancellationToken)); } - -export default Async; diff --git a/src/fable-library-ts/AsyncBuilder.ts b/src/fable-library-ts/AsyncBuilder.ts index 7ddec8abf..5abeffc67 100644 --- a/src/fable-library-ts/AsyncBuilder.ts +++ b/src/fable-library-ts/AsyncBuilder.ts @@ -86,9 +86,9 @@ export interface IAsyncContext { trampoline: Trampoline; } -export type IAsync = (x: IAsyncContext) => void; +export type Async = (x: IAsyncContext) => void; -export function protectedCont(f: IAsync) { +export function protectedCont(f: Async) { return (ctx: IAsyncContext) => { if (ctx.cancelToken.isCancelled) { ctx.onCancel(new OperationCanceledError()); @@ -110,7 +110,7 @@ export function protectedCont(f: IAsync) { }; } -export function protectedBind(computation: IAsync, binder: (x: T) => IAsync) { +export function protectedBind(computation: Async, binder: (x: T) => Async) { return protectedCont((ctx: IAsyncContext) => { computation({ onSuccess: (x: T) => { @@ -133,19 +133,19 @@ export function protectedReturn(value: T) { } export class AsyncBuilder { - public Bind(computation: IAsync, binder: (x: T) => IAsync) { + public Bind(computation: Async, binder: (x: T) => Async) { return protectedBind(computation, binder); } - public Combine(computation1: IAsync, computation2: IAsync) { + public Combine(computation1: Async, computation2: Async) { return this.Bind(computation1, () => computation2); } - public Delay(generator: () => IAsync) { + public Delay(generator: () => Async) { return protectedCont((ctx: IAsyncContext) => generator()(ctx)); } - public For(sequence: Iterable, body: (x: T) => IAsync) { + public For(sequence: Iterable, body: (x: T) => Async) { const iter = sequence[Symbol.iterator](); let cur = iter.next(); return this.While(() => !cur.done, this.Delay(() => { @@ -155,15 +155,15 @@ export class AsyncBuilder { })); } - public Return(value?: T) { + public Return(value: T) { return protectedReturn(value); } - public ReturnFrom(computation: IAsync) { + public ReturnFrom(computation: Async) { return computation; } - public TryFinally(computation: IAsync, compensation: () => void) { + public TryFinally(computation: Async, compensation: () => void) { return protectedCont((ctx: IAsyncContext) => { computation({ onSuccess: (x: T) => { @@ -184,7 +184,7 @@ export class AsyncBuilder { }); } - public TryWith(computation: IAsync, catchHandler: (e: any) => IAsync) { + public TryWith(computation: Async, catchHandler: (e: any) => Async) { return protectedCont((ctx: IAsyncContext) => { computation({ onSuccess: ctx.onSuccess, @@ -202,11 +202,11 @@ export class AsyncBuilder { }); } - public Using(resource: T, binder: (x: T) => IAsync) { + public Using(resource: T, binder: (x: T) => Async) { return this.TryFinally(binder(resource), () => resource.Dispose()); } - public While(guard: () => boolean, computation: IAsync): IAsync { + public While(guard: () => boolean, computation: Async): Async { if (guard()) { return this.Bind(computation, () => this.While(guard, computation)); } else { diff --git a/src/fable-library-ts/CHANGELOG.md b/src/fable-library-ts/CHANGELOG.md index c236a7648..482363ce3 100644 --- a/src/fable-library-ts/CHANGELOG.md +++ b/src/fable-library-ts/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 1.6.0 - 2024-10-02 + +### Removed + +* Remove `Async` (from `Async.ts`) class (by @MangelMaxime) + +### Changed + +* Renamed `IAsync` to `Async` in `AsyncBuilder.ts` (#3906) (by @ncave) + ## 1.5.0 - 2024-09-19 ### Added diff --git a/src/fable-library-ts/MailboxProcessor.ts b/src/fable-library-ts/MailboxProcessor.ts index e72ad0e18..90dbbf4ac 100644 --- a/src/fable-library-ts/MailboxProcessor.ts +++ b/src/fable-library-ts/MailboxProcessor.ts @@ -1,7 +1,7 @@ import { defaultCancellationToken } from "./Async.js"; import { fromContinuations } from "./Async.js"; import { startImmediate } from "./Async.js"; -import { IAsync } from "./AsyncBuilder.js"; +import { Async } from "./AsyncBuilder.js"; import { Continuation, Continuations } from "./AsyncBuilder.js"; import { CancellationToken } from "./AsyncBuilder.js"; @@ -41,7 +41,7 @@ class MailboxQueue { } } -export type MailboxBody = (m: MailboxProcessor) => IAsync; +export type MailboxBody = (m: MailboxProcessor) => Async; export interface AsyncReplyChannel { reply: (r: Reply) => void; diff --git a/src/fable-library-ts/package.json b/src/fable-library-ts/package.json index 5055f6fca..08e2aadc6 100644 --- a/src/fable-library-ts/package.json +++ b/src/fable-library-ts/package.json @@ -3,7 +3,7 @@ "private": false, "type": "module", "name": "@fable-org/fable-library-ts", - "version": "1.5.0", + "version": "1.6.0", "description": "Core library used by F# projects compiled with fable.io", "author": "Fable Contributors", "license": "MIT", diff --git a/src/fable-standalone/CHANGELOG.md b/src/fable-standalone/CHANGELOG.md index 2b143442f..847751414 100644 --- a/src/fable-standalone/CHANGELOG.md +++ b/src/fable-standalone/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 1.10.0 - 2024-10-02 + +* Fable 4.22.0 + ## 1.9.0 - 2024-09-19 * Fable 4.21.0 diff --git a/src/fable-standalone/package-lock.json b/src/fable-standalone/package-lock.json index 6e5a63236..77bdbf484 100644 --- a/src/fable-standalone/package-lock.json +++ b/src/fable-standalone/package-lock.json @@ -366,9 +366,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.1.5.tgz", - "integrity": "sha512-/fwx6GS8cIbM2rTNyLMxjSCOegHywOdXO+kN9yFy018iCULcKZCyA3xvzw4bxyKbYfdSxQgdhbsl0egNcxerQw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], @@ -379,9 +379,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.1.5.tgz", - "integrity": "sha512-tmXh7dyEt+JEz/NgDJlB1UeL/1gFV0v8qYzUAU42WZH4lmUJ5rp6/HkR2qUNC5jCgYEwd8/EfbHKtGIEfS4CUg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], @@ -392,9 +392,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.1.5.tgz", - "integrity": "sha512-lTDmLxdEVhzI3KCesZUrNbl3icBvPrDv/85JasY5gh4P2eAuDFmM4uj9HC5DdH0anLC0fwJ+1Uzasr4qOXcjRQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], @@ -405,9 +405,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.1.5.tgz", - "integrity": "sha512-v6qEHZyjWnIgcc4oiy8AIeFsUJAx+Kg0sLj+RE7ICwv3u7YC/+bSClxAiBASRjMzqsq0Z+I/pfxj+OD8mjBYxg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], @@ -418,9 +418,22 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.1.5.tgz", - "integrity": "sha512-WngCfwPEDUNbZR1FNO2TCROYUwJvRlbvPi3AS85bDUkkoRDBcjUIz42cuB1j4PKilmnZascL5xTMF/yU8YFayA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "cpu": [ "arm" ], @@ -431,9 +444,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.1.5.tgz", - "integrity": "sha512-Q2A/PEP/UTPTOBwgar3mmCaApahoezai/8e/7f4GCLV6XWCpnU4YwkQQtla7d7nUnc792Ps7g1G0WMovzIknrA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], @@ -444,9 +457,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.1.5.tgz", - "integrity": "sha512-84aBKNAVzTU/eG3tb2+kR4NGRAtm2YVW/KHwkGGDR4z1k4hyrDbuImsfs/6J74t6y0YLOe9HOSu7ejRjzUBGVQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], @@ -456,10 +469,49 @@ "linux" ] }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.1.5.tgz", - "integrity": "sha512-mldtP9UEBurIq2+GYMdNeiqCLW1fdgf4KdkMR/QegAeXk4jFHkKQl7p0NITrKFVyVqzISGXH5gR6GSTBH4wszw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], @@ -470,9 +522,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.1.5.tgz", - "integrity": "sha512-36p+nMcSxjAEzfU47+by102HolUtf/EfgBAidocTKAofJMTqG5QD50qzaFLk4QO+z7Qvg4qd0wr99jGAwnKOig==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], @@ -483,9 +535,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.1.5.tgz", - "integrity": "sha512-5oxhubo0A3J8aF/tG+6jHBg785HF8/88kl1YnfbDKmnqMxz/EFiAQDH9cq6lbnxofjn8tlq5KiTf0crJGOGThg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], @@ -496,9 +548,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.1.5.tgz", - "integrity": "sha512-uVQyBREKX9ErofL8KAZ4iVlqzSZOXSIG+BOLYuz5FD+Cg6jh1eLIeUa3Q4SgX0QaTRFeeAgSNqCC+8kZrZBpSw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], @@ -509,9 +561,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.1.5.tgz", - "integrity": "sha512-FQ5qYqRJ2vUBSom3Fos8o/6UvAMOvlus4+HGCAifH1TagbbwVnVVe0o01J1V52EWnQ8kmfpJDJ0FMrfM5yzcSA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], @@ -521,6 +573,12 @@ "win32" ] }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/esbuild": { "version": "0.19.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", @@ -573,10 +631,13 @@ } }, "node_modules/rollup": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.1.5.tgz", - "integrity": "sha512-AEw14/q4NHYQkQlngoSae2yi7hDBeT9w84aEzdgCr39+2RL+iTG84lGTkgC1Wp5igtquN64cNzuzZKVz+U6jOg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, + "dependencies": { + "@types/estree": "1.0.5" + }, "bin": { "rollup": "dist/bin/rollup" }, @@ -585,18 +646,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.1.5", - "@rollup/rollup-android-arm64": "4.1.5", - "@rollup/rollup-darwin-arm64": "4.1.5", - "@rollup/rollup-darwin-x64": "4.1.5", - "@rollup/rollup-linux-arm-gnueabihf": "4.1.5", - "@rollup/rollup-linux-arm64-gnu": "4.1.5", - "@rollup/rollup-linux-arm64-musl": "4.1.5", - "@rollup/rollup-linux-x64-gnu": "4.1.5", - "@rollup/rollup-linux-x64-musl": "4.1.5", - "@rollup/rollup-win32-arm64-msvc": "4.1.5", - "@rollup/rollup-win32-ia32-msvc": "4.1.5", - "@rollup/rollup-win32-x64-msvc": "4.1.5", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } } @@ -757,89 +822,123 @@ "optional": true }, "@rollup/rollup-android-arm-eabi": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.1.5.tgz", - "integrity": "sha512-/fwx6GS8cIbM2rTNyLMxjSCOegHywOdXO+kN9yFy018iCULcKZCyA3xvzw4bxyKbYfdSxQgdhbsl0egNcxerQw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "dev": true, "optional": true }, "@rollup/rollup-android-arm64": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.1.5.tgz", - "integrity": "sha512-tmXh7dyEt+JEz/NgDJlB1UeL/1gFV0v8qYzUAU42WZH4lmUJ5rp6/HkR2qUNC5jCgYEwd8/EfbHKtGIEfS4CUg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "dev": true, "optional": true }, "@rollup/rollup-darwin-arm64": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.1.5.tgz", - "integrity": "sha512-lTDmLxdEVhzI3KCesZUrNbl3icBvPrDv/85JasY5gh4P2eAuDFmM4uj9HC5DdH0anLC0fwJ+1Uzasr4qOXcjRQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "dev": true, "optional": true }, "@rollup/rollup-darwin-x64": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.1.5.tgz", - "integrity": "sha512-v6qEHZyjWnIgcc4oiy8AIeFsUJAx+Kg0sLj+RE7ICwv3u7YC/+bSClxAiBASRjMzqsq0Z+I/pfxj+OD8mjBYxg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "dev": true, "optional": true }, "@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.1.5.tgz", - "integrity": "sha512-WngCfwPEDUNbZR1FNO2TCROYUwJvRlbvPi3AS85bDUkkoRDBcjUIz42cuB1j4PKilmnZascL5xTMF/yU8YFayA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm-musleabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "dev": true, "optional": true }, "@rollup/rollup-linux-arm64-gnu": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.1.5.tgz", - "integrity": "sha512-Q2A/PEP/UTPTOBwgar3mmCaApahoezai/8e/7f4GCLV6XWCpnU4YwkQQtla7d7nUnc792Ps7g1G0WMovzIknrA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "dev": true, "optional": true }, "@rollup/rollup-linux-arm64-musl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.1.5.tgz", - "integrity": "sha512-84aBKNAVzTU/eG3tb2+kR4NGRAtm2YVW/KHwkGGDR4z1k4hyrDbuImsfs/6J74t6y0YLOe9HOSu7ejRjzUBGVQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-riscv64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-s390x-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", "dev": true, "optional": true }, "@rollup/rollup-linux-x64-gnu": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.1.5.tgz", - "integrity": "sha512-mldtP9UEBurIq2+GYMdNeiqCLW1fdgf4KdkMR/QegAeXk4jFHkKQl7p0NITrKFVyVqzISGXH5gR6GSTBH4wszw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "dev": true, "optional": true }, "@rollup/rollup-linux-x64-musl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.1.5.tgz", - "integrity": "sha512-36p+nMcSxjAEzfU47+by102HolUtf/EfgBAidocTKAofJMTqG5QD50qzaFLk4QO+z7Qvg4qd0wr99jGAwnKOig==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "dev": true, "optional": true }, "@rollup/rollup-win32-arm64-msvc": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.1.5.tgz", - "integrity": "sha512-5oxhubo0A3J8aF/tG+6jHBg785HF8/88kl1YnfbDKmnqMxz/EFiAQDH9cq6lbnxofjn8tlq5KiTf0crJGOGThg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "dev": true, "optional": true }, "@rollup/rollup-win32-ia32-msvc": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.1.5.tgz", - "integrity": "sha512-uVQyBREKX9ErofL8KAZ4iVlqzSZOXSIG+BOLYuz5FD+Cg6jh1eLIeUa3Q4SgX0QaTRFeeAgSNqCC+8kZrZBpSw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "dev": true, "optional": true }, "@rollup/rollup-win32-x64-msvc": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.1.5.tgz", - "integrity": "sha512-FQ5qYqRJ2vUBSom3Fos8o/6UvAMOvlus4+HGCAifH1TagbbwVnVVe0o01J1V52EWnQ8kmfpJDJ0FMrfM5yzcSA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "dev": true, "optional": true }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "esbuild": { "version": "0.19.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", @@ -878,23 +977,28 @@ "optional": true }, "rollup": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.1.5.tgz", - "integrity": "sha512-AEw14/q4NHYQkQlngoSae2yi7hDBeT9w84aEzdgCr39+2RL+iTG84lGTkgC1Wp5igtquN64cNzuzZKVz+U6jOg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, "requires": { - "@rollup/rollup-android-arm-eabi": "4.1.5", - "@rollup/rollup-android-arm64": "4.1.5", - "@rollup/rollup-darwin-arm64": "4.1.5", - "@rollup/rollup-darwin-x64": "4.1.5", - "@rollup/rollup-linux-arm-gnueabihf": "4.1.5", - "@rollup/rollup-linux-arm64-gnu": "4.1.5", - "@rollup/rollup-linux-arm64-musl": "4.1.5", - "@rollup/rollup-linux-x64-gnu": "4.1.5", - "@rollup/rollup-linux-x64-musl": "4.1.5", - "@rollup/rollup-win32-arm64-msvc": "4.1.5", - "@rollup/rollup-win32-ia32-msvc": "4.1.5", - "@rollup/rollup-win32-x64-msvc": "4.1.5", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", + "@types/estree": "1.0.5", "fsevents": "~2.3.2" } } diff --git a/src/fable-standalone/package.json b/src/fable-standalone/package.json index 6f026f657..b1c95ae59 100644 --- a/src/fable-standalone/package.json +++ b/src/fable-standalone/package.json @@ -2,7 +2,7 @@ "type": "module", "name": "@fable-org/fable-standalone", "private": false, - "version": "1.9.0", + "version": "1.10.0", "main": "./dist/bundle.min.js", "description": "Fable compiler", "keywords": [ diff --git a/tests/Js/Main/AsyncTests.fs b/tests/Js/Main/AsyncTests.fs index c328f62ff..4e4044896 100644 --- a/tests/Js/Main/AsyncTests.fs +++ b/tests/Js/Main/AsyncTests.fs @@ -547,7 +547,7 @@ let tests = equal x "ABCDEF" } - testCaseAsync "Async.StartChild applys timeout" <| fun () -> + testCaseAsync "Async.StartChild applies timeout" <| fun () -> async { let mutable x = "" diff --git a/tests/Php/Util.fs b/tests/Php/Util.fs index c9c457d13..896a36590 100644 --- a/tests/Php/Util.fs +++ b/tests/Php/Util.fs @@ -16,7 +16,7 @@ module Testing = let equal expected actual: unit = Assert.AreEqual(actual, expected) let notEqual expected actual: unit = Assert.NotEqual(actual, expected) - type Fact() = inherit System.Attribute() + type FactAttribute() = inherit System.Attribute() #else open Xunit type FactAttribute = Xunit.FactAttribute diff --git a/tests/Python/Util.fs b/tests/Python/Util.fs index ef00ca0c8..e80a7e956 100644 --- a/tests/Python/Util.fs +++ b/tests/Python/Util.fs @@ -11,7 +11,7 @@ module Testing = let equal expected actual: unit = Assert.AreEqual(actual, expected) let notEqual expected actual: unit = Assert.NotEqual(actual, expected) - type Fact() = inherit System.Attribute() + type FactAttribute() = inherit System.Attribute() #else open Xunit type FactAttribute = Xunit.FactAttribute diff --git a/tests/Rust/tests/src/AsyncTests.fs b/tests/Rust/tests/src/AsyncTests.fs index cc8dfdb81..a7c17c8de 100644 --- a/tests/Rust/tests/src/AsyncTests.fs +++ b/tests/Rust/tests/src/AsyncTests.fs @@ -102,7 +102,6 @@ let shouldExecuteTask () = // t.Join() // x |> equal 2 - // [] // let monitorShouldWorkWithSystemObj () = // let o = new System.Object() // todo - this doesn't work, and outputs unit @@ -175,6 +174,24 @@ let ``Lock should return result`` () = // do t.Result // x |> equal 2 +[] +let ``Async.Sleep works`` () = + let mutable s = "" + let a1 = + async { + do! Async.Sleep(200) + s <- s + "200" + } + let a2 = + async { + do! Async.Sleep(100) + s <- s + "100" + } + let t1 = a1 |> Async.StartAsTask + let t2 = a2 |> Async.StartAsTask + let r1 = t1.Result + let r2 = t2.Result + s |> equal "100200" // type DisposableAction(f) = // interface IDisposable with @@ -588,7 +605,6 @@ let ``Lock should return result`` () = // Async.StartWithContinuations(work, (fun r -> result <- r), ignore, ignore) // equal result 42 - // [] // let ``Deep recursion with async doesn't cause stack overflow`` () = // async { @@ -744,7 +760,7 @@ let ``Lock should return result`` () = // |> Async.StartImmediate // [] -// let ``Async.StartChild applys timeout`` () = +// let ``Async.StartChild applies timeout`` () = // async { // let mutable x = "" // let task = async { diff --git a/tests/Rust/tests/src/ClassTests.fs b/tests/Rust/tests/src/ClassTests.fs index 1734dddc2..c64aeb1e9 100644 --- a/tests/Rust/tests/src/ClassTests.fs +++ b/tests/Rust/tests/src/ClassTests.fs @@ -1,6 +1,7 @@ module Fable.Tests.ClassTests open Util.Testing +open Common.Imports [] type Point(x: float, y: float) = @@ -51,10 +52,10 @@ type FluentB(a: FluentA) = a type WithCrossModuleInterface(m: int) = - interface Common.Imports.IHasAdd with + interface IHasAdd with member this.Add x y = x + y + m -type AdderWrapper<'a when 'a :> Common.Imports.IHasAdd> (adder: 'a) = +type AdderWrapper<'a when 'a :> IHasAdd> (adder: 'a) = member this.AddThroughCaptured x y = adder.Add x y type TestClass(name: string) = @@ -70,14 +71,26 @@ type IPrintable2 = abstract Print2: unit -> string [] -let ``Object expressions work`` () = +let ``Object expression from interface works`` () = let a = { new IPrintable with member x.Print() = "Hello" } a.Print() |> equal "Hello" - let b = { new Common.Imports.IHasAdd with member _.Add x y = x + y } + let b = { new IHasAdd with member _.Add x y = x + y } b.Add 2 3 |> equal 5 [] -let ``Object expressions instance calls work`` () = +let ``Object expression from obj works`` () = + let a = { new obj() with + override _.ToString() = "Hello" } + a.ToString() |> equal "Hello" + let b = { new obj() with + override _.ToString() = "Adder" + interface IHasAdd with + member _.Add x y = x + y } + // b.ToString() |> equal "Adder" // TODO: enable once lrc_ptr is default + (b :> IHasAdd).Add 2 3 |> equal 5 + +[] +let ``Object expression instance calls works`` () = let a = { new IPrintable2 with member _.Print() = "Hello" member x.Print2() = x.Print() } @@ -168,7 +181,7 @@ let ``Class fluent/builder should be sharing same reference and not cloning when [] let ``Class interface from another module works`` () = let a = WithCrossModuleInterface(1) - let res = (a :> Common.Imports.IHasAdd).Add 2 1 + let res = (a :> IHasAdd).Add 2 1 res |> equal 4 [] @@ -180,11 +193,11 @@ let ``Class generic interface constraints work`` () = [] let ``Class methods imported from another file work`` () = - let a = Common.Imports.MyClass() - let res = (a :> Common.Imports.IHasAdd).Add 2 3 + let a = MyClass() + let res = (a :> IHasAdd).Add 2 3 res |> equal 5 a.Sub 2 3 |> equal -1 - Common.Imports.MyClass.Mul 2 3 |> equal 6 + MyClass.Mul 2 3 |> equal 6 #if FABLE_COMPILER open Fable.Core diff --git a/tests/Rust/tests/src/ComparisonTests.fs b/tests/Rust/tests/src/ComparisonTests.fs index a450935ef..498bafdad 100644 --- a/tests/Rust/tests/src/ComparisonTests.fs +++ b/tests/Rust/tests/src/ComparisonTests.fs @@ -475,8 +475,12 @@ let ``min works with records`` () = [] let ``GetHashCode with arrays works`` () = - ([|1; 2|].GetHashCode(), [|1; 2|].GetHashCode()) ||> notEqual - ([|2; 1|].GetHashCode(), [|1; 2|].GetHashCode()) ||> notEqual + let o1 = [|1; 2|] + let o2 = [|1; 2|] + let o3 = [|2; 1|] + (o1.GetHashCode(), o1.GetHashCode()) ||> equal + (o2.GetHashCode(), o1.GetHashCode()) ||> notEqual + (o3.GetHashCode(), o1.GetHashCode()) ||> notEqual [] let ``GetHashCode with lists works`` () = @@ -513,8 +517,12 @@ let ``GetHashCode with structs works`` () = [] let ``GetHashCode with objects works`` () = - (OTest(1).GetHashCode(), OTest(1).GetHashCode()) ||> notEqual - (OTest(2).GetHashCode(), OTest(1).GetHashCode()) ||> notEqual + let o1 = OTest(1) + let o2 = OTest(1) + let o3 = OTest(2) + (o1.GetHashCode(), o1.GetHashCode()) ||> equal + (o2.GetHashCode(), o1.GetHashCode()) ||> notEqual + (o3.GetHashCode(), o1.GetHashCode()) ||> notEqual // [] // let ``GetHashCode with objects that overwrite it works`` () = @@ -581,8 +589,19 @@ let ``hash with structs works`` () = [] let ``hash with objects works`` () = - (hash (OTest(1)), hash (OTest(1))) ||> notEqual - (hash (OTest(2)), hash (OTest(1))) ||> notEqual + // In Release mode for Rust, sequentially allocated objects that + // are immediately released can get allocated at the same address. + // This breaks referential equality, so delaying their release by + // increasing their scope makes it work. See ReferenceEquals tests. + // + // (hash (OTest(1)), hash (OTest(1))) ||> notEqual // broken in Release mode + // (hash (OTest(2)), hash (OTest(1))) ||> notEqual // broken in Release mode + let o1 = OTest(1) + let o2 = OTest(1) + let o3 = OTest(2) + (hash o1, hash o1) ||> equal + (hash o2, hash o1) ||> notEqual + (hash o3, hash o1) ||> notEqual [] let ``hash with same object works`` () = @@ -687,18 +706,30 @@ let ``LanguagePrimitives.PhysicalHash with primitives works`` () = [] let ``LanguagePrimitives.PhysicalHash with lists works`` () = - (LanguagePrimitives.PhysicalHash [1;2], LanguagePrimitives.PhysicalHash [1;2]) ||> notEqual - (LanguagePrimitives.PhysicalHash [2;1], LanguagePrimitives.PhysicalHash [1;2]) ||> notEqual + let o1 = [1; 2] + let o2 = [1; 2] + let o3 = [2; 1] + (LanguagePrimitives.PhysicalHash o1, LanguagePrimitives.PhysicalHash o1) ||> equal + (LanguagePrimitives.PhysicalHash o2, LanguagePrimitives.PhysicalHash o1) ||> notEqual + (LanguagePrimitives.PhysicalHash o3, LanguagePrimitives.PhysicalHash o1) ||> notEqual [] let ``LanguagePrimitives.PhysicalHash with arrays works`` () = - (LanguagePrimitives.PhysicalHash [|1;2|], LanguagePrimitives.PhysicalHash [|1;2|]) ||> notEqual - (LanguagePrimitives.PhysicalHash [|2;1|], LanguagePrimitives.PhysicalHash [|1;2|]) ||> notEqual + let o1 = [|1; 2|] + let o2 = [|1; 2|] + let o3 = [|2; 1|] + (LanguagePrimitives.PhysicalHash o1, LanguagePrimitives.PhysicalHash o1) ||> equal + (LanguagePrimitives.PhysicalHash o2, LanguagePrimitives.PhysicalHash o1) ||> notEqual + (LanguagePrimitives.PhysicalHash o3, LanguagePrimitives.PhysicalHash o1) ||> notEqual [] let ``LanguagePrimitives.PhysicalHash with tuples works`` () = - (LanguagePrimitives.PhysicalHash (1,2), LanguagePrimitives.PhysicalHash (1,2)) ||> notEqual - (LanguagePrimitives.PhysicalHash (2,1), LanguagePrimitives.PhysicalHash (1,2)) ||> notEqual + let o1 = (1, 2) + let o2 = (1, 2) + let o3 = (2, 1) + (LanguagePrimitives.PhysicalHash o1, LanguagePrimitives.PhysicalHash o1) ||> equal + (LanguagePrimitives.PhysicalHash o2, LanguagePrimitives.PhysicalHash o1) ||> notEqual + (LanguagePrimitives.PhysicalHash o3, LanguagePrimitives.PhysicalHash o1) ||> notEqual [] let ``LanguagePrimitives.GenericComparison works`` () = diff --git a/tests/Rust/tests/src/ResizeArrayTests.fs b/tests/Rust/tests/src/ResizeArrayTests.fs index 397af0186..b92119039 100644 --- a/tests/Rust/tests/src/ResizeArrayTests.fs +++ b/tests/Rust/tests/src/ResizeArrayTests.fs @@ -32,31 +32,37 @@ let ``ResizeArray casting to seq works`` () = let xs = ResizeArray<_>(seq{1;2;3;4;5}) :> seq<_> Seq.sum xs |> equal 15 -// [] -// let ``ResizeArray iteration works`` () = -// let xs = ResizeArray<_>() -// xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) -// let mutable acc = 0. -// for i in xs do -// acc <- acc + i -// acc |> equal 15. - -// [] -// let ``ResizeArray iteration with index works`` () = -// let xs = ResizeArray<_>() -// for i = 1 to 4 do -// xs.Add(i) -// let mutable x = 0 -// for i = 0 to xs.Count - 1 do -// x <- x + xs[i] -// x |> equal 10 - -// [] -// let ``ResizeArray folding works`` () = -// let xs = ResizeArray<_>() -// xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) -// xs |> Seq.fold (fun acc item -> acc + item) 0. -// |> equal 15. +[] +let ``ResizeArray iteration works`` () = + let xs = ResizeArray<_>() + xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) + let mutable acc = 0. + for i in xs do + acc <- acc + i + acc |> equal 15. + +[] +let ``ResizeArray iteration with index works`` () = + let xs = ResizeArray<_>() + for i = 1 to 4 do + xs.Add(i) + let mutable x = 0 + for i = 0 to xs.Count - 1 do + x <- x + xs[i] + x |> equal 10 + +[] +let ``ResizeArray folding works`` () = + let xs = ResizeArray<_>() + xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) + let sum = xs |> Seq.fold (fun acc item -> acc + item) 0. + sum |> equal 15. + +[] +let ``ResizeArray.Capacity works`` () = + let xs = ResizeArray(42) + xs.Capacity |> equal 42 + xs.Count |> equal 0 [] let ``ResizeArray.Count works`` () = @@ -64,69 +70,69 @@ let ``ResizeArray.Count works`` () = xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) xs.Count |> equal 5 -// [] -// let ``ResizeArray.ConvertAll works`` () = -// let xs = ResizeArray<_> [1.; 2.; 3.; 4.] -// let ys = xs.ConvertAll(System.Converter(fun x -> int x)) -// ys |> Seq.toList |> equal [1;2;3;4] - -// [] -// let ``ResizeArray.Find works`` () = -// let xs = ResizeArray<_>() -// xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) -// System.Predicate<_> (fun x -> x = 1.) |> xs.Find |> equal 1. -// System.Predicate<_> (fun x -> x = -1.) |> xs.Find |> equal 0. - -// [] -// let ``ResizeArray.Find with option works`` () = -// let xs = ResizeArray<_>() -// xs.Add(Some 1); xs.Add(None); -// System.Predicate<_> (fun _ -> true) |> xs.Find |> equal (Some 1) -// System.Predicate<_> (fun _ -> false) |> xs.Find |> equal None -// System.Predicate<_> Option.isNone |> xs.Find |> equal None -// System.Predicate<_> Option.isSome |> xs.Find |> equal (Some 1) - -// [] -// let ``ResizeArray.FindAll works`` () = -// let xs = ResizeArray<_> [1.; 2.; 3.; 4.] -// System.Predicate<_> (fun x -> x <= 3.) |> xs.FindAll |> (fun l -> l.Count) |> equal 3 -// System.Predicate<_> (fun x -> x = 5.) |> xs.FindAll |> (fun l -> l.Count) |> equal 0 - -// [] -// let ``ResizeArray.FindLast works`` () = -// let xs = ResizeArray<_>() -// xs.Add(1.,0.); xs.Add(2.,0.); xs.Add(3.,0.); xs.Add(4.,0.); xs.Add(5.,0.); xs.Add(1.,1.) -// System.Predicate<_> (fun (x, _) -> x = 1.) |> xs.FindLast |> snd |> equal 1. - -// [] -// let ``ResizeArray.FindLast with option works`` () = -// let xs = ResizeArray<_>() -// xs.Add(Some 1); xs.Add(None); -// System.Predicate<_> (fun _ -> true) |> xs.FindLast |> equal None -// System.Predicate<_> (fun _ -> false) |> xs.FindLast |> equal None -// System.Predicate<_> Option.isSome |> xs.FindLast |> equal (Some 1) - -// [] -// let ``ResizeArray.FindIndex works`` () = -// let xs = ResizeArray<_>() -// xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(2.); xs.Add(5.) -// System.Predicate<_> (fun x -> x = 2.) |> xs.FindIndex |> equal 1 -// System.Predicate<_> (fun x -> x = 0.) |> xs.FindIndex |> equal -1 - -// [] -// let ``ResizeArray.FindLastIndex works`` () = -// let xs = ResizeArray<_>() -// xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(2.); xs.Add(5.) -// System.Predicate<_> (fun x -> x = 2.) |> xs.FindLastIndex |> equal 3 -// System.Predicate<_> (fun x -> x = 0.) |> xs.FindLastIndex |> equal -1 - -// [] -// let ``ResizeArray.ForEach works`` () = -// let xs = ResizeArray<_>() -// let mutable sum = 0 -// xs.Add(1); xs.Add(2); xs.Add(3); xs.Add(4); xs.Add(5) -// System.Action<_> (fun x -> sum <- sum + x) |> xs.ForEach -// sum |> equal 15 +[] +let ``ResizeArray.ConvertAll works`` () = + let xs = ResizeArray<_> [1.; 2.; 3.; 4.] + let ys = xs.ConvertAll(System.Converter(fun x -> int x)) + ys |> Seq.toList |> equal [1;2;3;4] + +[] +let ``ResizeArray.Find works`` () = + let xs = ResizeArray<_>() + xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) + System.Predicate<_> (fun x -> x = 1.) |> xs.Find |> equal 1. + System.Predicate<_> (fun x -> x = -1.) |> xs.Find |> equal 0. + +[] +let ``ResizeArray.Find with option works`` () = + let xs = ResizeArray<_>() + xs.Add(Some 1); xs.Add(None); + System.Predicate<_> (fun _ -> true) |> xs.Find |> equal (Some 1) + System.Predicate<_> (fun _ -> false) |> xs.Find |> equal None + System.Predicate<_> Option.isNone |> xs.Find |> equal None + System.Predicate<_> Option.isSome |> xs.Find |> equal (Some 1) + +[] +let ``ResizeArray.FindAll works`` () = + let xs = ResizeArray<_> [1.; 2.; 3.; 4.] + System.Predicate<_> (fun x -> x <= 3.) |> xs.FindAll |> (fun l -> l.Count) |> equal 3 + System.Predicate<_> (fun x -> x = 5.) |> xs.FindAll |> (fun l -> l.Count) |> equal 0 + +[] +let ``ResizeArray.FindLast works`` () = + let xs = ResizeArray<_>() + xs.Add(1.,0.); xs.Add(2.,0.); xs.Add(3.,0.); xs.Add(4.,0.); xs.Add(5.,0.); xs.Add(1.,1.) + System.Predicate<_> (fun (x, _) -> x = 1.) |> xs.FindLast |> snd |> equal 1. + +[] +let ``ResizeArray.FindLast with option works`` () = + let xs = ResizeArray<_>() + xs.Add(Some 1); xs.Add(None); + System.Predicate<_> (fun _ -> true) |> xs.FindLast |> equal None + System.Predicate<_> (fun _ -> false) |> xs.FindLast |> equal None + System.Predicate<_> Option.isSome |> xs.FindLast |> equal (Some 1) + +[] +let ``ResizeArray.FindIndex works`` () = + let xs = ResizeArray<_>() + xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(2.); xs.Add(5.) + System.Predicate<_> (fun x -> x = 2.) |> xs.FindIndex |> equal 1 + System.Predicate<_> (fun x -> x = 0.) |> xs.FindIndex |> equal -1 + +[] +let ``ResizeArray.FindLastIndex works`` () = + let xs = ResizeArray<_>() + xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(2.); xs.Add(5.) + System.Predicate<_> (fun x -> x = 2.) |> xs.FindLastIndex |> equal 3 + System.Predicate<_> (fun x -> x = 0.) |> xs.FindLastIndex |> equal -1 + +[] +let ``ResizeArray.ForEach works`` () = + let xs = ResizeArray<_>() + let mutable sum = 0 + xs.Add(1); xs.Add(2); xs.Add(3); xs.Add(4); xs.Add(5) + System.Action<_> (fun x -> sum <- sum + x) |> xs.ForEach + sum |> equal 15 [] let ``ResizeArray indexer getter works`` () = @@ -139,7 +145,7 @@ let ``ResizeArray indexer setter works`` () = let xs = ResizeArray<_>() xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) xs[3] <- 10. - xs[3] |> equal 10. + xs.ToArray() |> equal [|1.;2.;3.;10.;5.|] [] let ``ResizeArray.Clear works`` () = @@ -152,29 +158,38 @@ let ``ResizeArray.Clear works`` () = let ``ResizeArray.Add works`` () = let xs = ResizeArray<_>() xs.Add(1.); xs.Add(2.); xs.Add(3.) - equal 3 xs.Count - -// [] -// let ``ResizeArray.AddRange works`` () = -// let xs = ResizeArray<_>() -// xs.AddRange [1;2;3] -// equal 3 xs.Count - -// [] -// let ``ResizeArray.InsertRange works`` () = -// let xs = ResizeArray<_>() -// let mutable sum = 0 -// xs.Add(1); xs.Add(2); xs.Add(5) -// xs.InsertRange(2, [3;4]) -// Seq.toList xs |> equal [1;2;3;4;5] - -// [] -// let ``ResizeArray.GetRange works`` () = -// let xs = ResizeArray<_>() -// xs.AddRange [1;2;3] -// let sub = xs.GetRange(1, 2) -// sub.Count |> equal 2 -// sub.Contains(1) |> equal false + xs.ToArray() |> equal [|1;2;3|] + +[] +let ``ResizeArray.AddRange works`` () = + let xs = ResizeArray<_>() + xs.AddRange [1;2;3] + xs.ToArray() |> equal [|1;2;3|] + +[] +let ``ResizeArray.Insert works`` () = + let xs = ResizeArray<_>([|1;2;3;4;5|]) + xs.Insert(2, 8) + xs.ToArray() |> equal [|1;2;8;3;4;5|] + +[] +let ``ResizeArray.InsertRange works`` () = + let xs = ResizeArray<_>() + xs.Add(1); xs.Add(2); xs.Add(5) + xs.InsertRange(2, [3;4]) + xs.ToArray() |> equal [|1;2;3;4;5|] + +[] +let ``ResizeArray.GetRange works`` () = + let xs = ResizeArray<_>([|1;2;3;4;5|]) + let ys = xs.GetRange(1, 2) + ys.ToArray() |> equal [|2;3|] + +[] +let ``ResizeArray.Slice works`` () = + let xs = ResizeArray<_>([|1;2;3;4;5|]) + let ys = xs.Slice(1, 2) + ys.ToArray() |> equal [|2;3|] [] let ``ResizeArray.Contains works`` () = @@ -186,38 +201,58 @@ let ``ResizeArray.Contains works`` () = [] let ``ResizeArray.IndexOf works`` () = + let xs = ResizeArray<_>([|3;2;1;3;2|]) + xs.IndexOf(2) |> equal 1 + xs.IndexOf(3) |> equal 0 + xs.IndexOf(4) |> equal -1 + +[] +let ``ResizeArray.IndexOf works II`` () = + let xs = ResizeArray<_>([|"T";"A";"M";"B";"D";"T";"C"|]) + xs.IndexOf("T") |> equal 0 + xs.IndexOf("T", 3) |> equal 5 + xs.IndexOf("T", 2, 2) |> equal -1 + +[] +let ``ResizeArray.LastIndexOf works`` () = + let xs = ResizeArray<_>([|3;2;1;3;2|]) + xs.LastIndexOf(2) |> equal 4 + xs.LastIndexOf(3) |> equal 3 + xs.LastIndexOf(4) |> equal -1 + +[] +let ``ResizeArray.LastIndexOf works II`` () = + let xs = ResizeArray<_>([|"T";"A";"M";"B";"D";"T";"C"|]) + xs.LastIndexOf("T") |> equal 5 + xs.LastIndexOf("T", 3) |> equal 0 + xs.LastIndexOf("T", 4, 4) |> equal -1 + +[] +let ``ResizeArray.Remove works`` () = + let xs = ResizeArray<_>() + xs.Add("ab") + xs.Add("ch") + xs.Remove("ab") |> equal true + xs.Remove("cd") |> equal false + +[] +let ``ResizeArray.RemoveAll works`` () = let xs = ResizeArray<_>() + xs.Add("ab") xs.Add("ch") xs.Add("ab") - xs.IndexOf("ab") |> equal 1 - xs.IndexOf("cd") |> equal -1 - -// [] -// let ``ResizeArray.Remove works`` () = -// let xs = ResizeArray<_>() -// xs.Add("ab") -// xs.Add("ch") -// xs.Remove("ab") |> equal true -// xs.Remove("cd") |> equal false - -// [] -// let ``ResizeArray.RemoveAll works`` () = -// let xs = ResizeArray<_>() -// xs.Add("ab") -// xs.Add("ch") -// xs.Add("ab") -// System.Predicate<_> (fun x -> x = "ab") |> xs.RemoveAll |> equal 2 -// System.Predicate<_> (fun x -> x = "ab") |> xs.RemoveAll |> equal 0 -// xs[0] |> equal "ch" - -// [] -// let ``ResizeArray.RemoveRange works`` () = -// let xs = ResizeArray() -// for x in [1 .. 5] do xs.Add(x) -// xs.RemoveRange(1, 2) // [1;2;3;4;5] -> [1;4;5] -// equal 1 xs[0] -// equal 4 xs[1] -// equal 5 xs[2] + System.Predicate<_> (fun x -> x = "ab") |> xs.RemoveAll |> equal 2 + System.Predicate<_> (fun x -> x = "ab") |> xs.RemoveAll |> equal 0 + xs[0] |> equal "ch" + +[] +let ``ResizeArray.RemoveRange works`` () = + let xs = ResizeArray() + for x in [1 .. 5] do xs.Add(x) + xs.RemoveRange(1, 2) // [1;2;3;4;5] -> [1;4;5] + equal 1 xs[0] + equal 4 xs[1] + equal 5 xs[2] [] let ``ResizeArray.Exists works`` () = @@ -235,81 +270,134 @@ let ``ResizeArray.RemoveAt works`` () = let xs = ResizeArray<_>() xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) xs.RemoveAt(2) - xs.Count |> equal 4 - xs[2] |> equal 4. + xs.ToArray() |> equal [|1.;2.;4.;5.|] [] -let ``ResizeArray.Insert works`` () = - let xs = ResizeArray<_>() - xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) - xs.Insert(2, 8.) - xs.Count |> equal 6 - xs[2] |> equal 8. - -[] -let ``ResizeArray.ReverseInPlace works`` () = +let ``ResizeArray.Reverse works`` () = let xs = ResizeArray<_>() xs.Add(1.); xs.Add(2.); xs.Add(3.); xs.Add(4.); xs.Add(5.) xs.Reverse() xs.ToArray() |> equal [|5.;4.;3.;2.;1.|] [] -let ``ResizeArray.SortInPlace works`` () = +let ``ResizeArray.Reverse works II`` () = + let xs = ResizeArray<_>([|1;2;3;4;5|]) + xs.Reverse(2, 3) + xs.Reverse(1, 2) + xs.ToArray() |> equal [|1;5;2;4;3|] + +[] +let ``ResizeArray.Sort works`` () = let xs = ResizeArray<_>() xs.Add("Ana"); xs.Add("Pedro"); xs.Add("Lucía"); xs.Add("Paco") xs.Sort() xs.ToArray() |> equal [|"Ana";"Lucía";"Paco";"Pedro"|] [] -let ``ResizeArray.SortInPlace works II`` () = +let ``ResizeArray.Sort works II`` () = let xs = ResizeArray [1;3;10;2] xs.Sort() xs.ToArray() |> equal [|1;2;3;10|] [] -let ``ResizeArray.SortInPlace works III`` () = +let ``ResizeArray.Sort works III`` () = let xs = ResizeArray [1.;3.;10.;2.] xs.Sort() xs.ToArray() |> equal [|1.;2.;3.;10.|] [] -let ``ResizeArray.SortInPlaceWith works`` () = +let ``ResizeArray.Sort works with custom comparison`` () = let xs = ResizeArray<_>() xs.Add(3.); xs.Add(6.); xs.Add(5.); xs.Add(4.); xs.Add(8.) xs.Sort(fun x y -> if x > y then -1 elif x < y then 1 else 0) xs.ToArray() |> equal [|8.;6.;5.;4.;3.|] [] -let ``ResizeArray.SortInPlaceWith works with custom comparison function`` () = // See #1386 - let xs = ResizeArray [1;3;2] +let ``ResizeArray.Sort works with custom comparison II`` () = // See #1386 + let xs = ResizeArray [1;5;2;3;4] xs.Sort(fun x y -> if x < y then 1 else -1) - xs.ToArray() |> equal [|3;2;1|] + xs.ToArray() |> equal [|5;4;3;2;1|] xs.Sort(compare) - xs.ToArray() |> equal [|1;2;3|] + xs.ToArray() |> equal [|1;2;3;4;5|] -// [] -// let ``ResizeArray.SortInPlaceWith works with custom comparer`` () = // See #1386 -// let xs = ResizeArray [1;3;2] -// let comparer = System.Collections.Generic.Comparer.Default -// xs.Sort(comparer) -// Seq.toList xs |> equal [1;2;3] +[] +let ``ResizeArray.Sort works with custom comparer`` () = // See #1386 + let xs = ResizeArray<_> [|1;5;2;3;4|] + let comparer = System.Collections.Generic.Comparer.Default + xs.Sort(comparer) + xs.ToArray() |> equal [|1;2;3;4;5|] + +[] +let ``ResizeArray.Sort works with custom comparer II`` () = // See #1386 + let xs = ResizeArray<_> [|1;5;2;3;4|] + let comparer = System.Collections.Generic.Comparer.Default + xs.Sort(1,3, comparer) + xs.ToArray() |> equal [|1;2;3;5;4|] [] let ``ResizeArray.ToArray works`` () = let xs = ResizeArray<_>() xs.Add(3.); xs.Add(6.); xs.Add(5.); xs.Add(4.); xs.Add(8.) xs.Count |> equal 5 - let ar = xs.ToArray() - Array.length ar |> equal 5 - ar[0] <- 2. - equal 3. xs[0] - equal 2. ar[0] - -[] -let ``ResizeArray.Item is undefined when index is out of range`` () = - let xs = ResizeArray [0] -#if FABLE_COMPILER_JAVASCRIPT - isNull <| box (xs.Item 1) |> equal true -#else - throwsAnyError (fun () -> (xs.Item 1) |> ignore) -#endif + xs.ToArray() |> equal [|3.;6.;5.;4.;8.|] + +[] +let ``ResizeArray.TrimExcess works`` () = + let xs = ResizeArray<_>(42) + xs.Add(3.); xs.Add(6.); xs.Add(5.); xs.Add(4.); xs.Add(8.) + xs.TrimExcess() + xs.Count |> equal 5 + xs.Capacity |> equal 5 + +[] +let ``ResizeArray.TrueForAll works`` () = + let xs = ResizeArray() + for x = 1 to 5 do xs.Add(x) + xs.TrueForAll (fun a -> a < 6) |> equal true + xs.TrueForAll (fun a -> a > 5) |> equal false + +[] +let ``ResizeArray.Item throws when index is out of range`` () = + let xs = ResizeArray [|1;2;3|] + throwsAnyError (fun () -> (xs.Item 3) |> ignore) + +[] +let ``ResizeArray.BinarySearch works`` () = + let xs = ResizeArray [|1;4;5;7;10;13|] + xs.BinarySearch(7) |> equal 3 + xs.BinarySearch(8) |> equal ~~~4 + +[] +let ``ResizeArray.BinarySearch works II`` () = + let xs = ResizeArray [|1;4;5;7;10;13|] + let comparer = System.Collections.Generic.Comparer.Default + xs.BinarySearch(7, comparer) |> equal 3 + xs.BinarySearch(8, comparer) |> equal ~~~4 + +[] +let ``ResizeArray.BinarySearch works III`` () = + let xs = ResizeArray [|1;4;5;7;10;13|] + let comparer = System.Collections.Generic.Comparer.Default + xs.BinarySearch(1, 3, 7, comparer) |> equal 3 + xs.BinarySearch(1, 2, 8, comparer) |> equal ~~~3 + +[] +let ``ResizeArray.CopyTo works`` () = + let xs = ResizeArray<_> [|1;2;3;4|] + let ys = [|5;6;7;8;9|] + xs.CopyTo(ys) + ys |> equal [|1;2;3;4;9|] + +[] +let ``ResizeArray.CopyTo works II`` () = + let xs = ResizeArray<_> [|1;2;3;4|] + let ys = [|5;6;7;8;9|] + xs.CopyTo(ys, 1) + ys |> equal [|5;1;2;3;4|] + +[] +let ``ResizeArray.CopyTo works III`` () = + let xs = ResizeArray<_> [|1;2;3;4|] + let ys = [|5;6;7;8;9|] + xs.CopyTo(2, ys, 1, 2) + ys |> equal [|5;3;4;8;9|] diff --git a/tests/Rust/tests/src/TypeTests.fs b/tests/Rust/tests/src/TypeTests.fs index 2ce0909ef..905753dee 100644 --- a/tests/Rust/tests/src/TypeTests.fs +++ b/tests/Rust/tests/src/TypeTests.fs @@ -119,17 +119,17 @@ let inline show< ^T when ^T : (member show : unit -> string)> (x:^T) : string = let inline showStatic< ^T when ^T : (static member show : ^T -> string)> (x:^T) : string = (^T : (static member show : ^T -> string) (x)) -// [] -// type Serializable(?i: int) = -// let mutable deserialized = false -// let mutable publicValue = 1 -// let mutable privateValue = defaultArg i 0 -// member x.PublicValue -// with get() = publicValue -// and set(i) = deserialized <- true; publicValue <- i -// override x.ToString() = -// sprintf "Public: %i - Private: %i - Deserialized: %b" -// publicValue privateValue deserialized +[] +type Serializable(?i: int) = + let mutable deserialized = false + let mutable publicValue = 1 + let mutable privateValue = defaultArg i 0 + member x.PublicValue + with get() = publicValue + and set(i) = deserialized <- true; publicValue <- i + override x.ToString() = + sprintf "Public: %i - Private: %i - Deserialized: %b" + publicValue privateValue deserialized type SecondaryCons(x: int) = new () = SecondaryCons(5)