You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Generated by ReScript, PLEASE EDIT WITH CAREfunctionisEmpty(x){return!x;}functionisNotEmpty(xs){returnxs;}export{isEmpty,isNotEmpty,}/* No side effect */
Whereas alphe.4 and before generates correctly (Playground):
// Generated by ReScript, PLEASE EDIT WITH CAREfunctionisEmpty(x){if(x){returnfalse;}else{returntrue;}}functionisNotEmpty(xs){return!(xs ? false : true);}export{isEmpty,isNotEmpty,}/* No side effect */
I found out this problem when porting [Relude](https://github.com/dsiu/rescript-relude) to rescript@v12. The following Jest tests fails:
test("isNotEmpty is false for empty list", () =>expect(List.isNotEmpty(list{}))->toBe(false))
test("isNotEmpty is true for non-empty list", () =>expect(List.isNotEmpty(list{1}))->toBe(true))
Summary of all failing tests
FAIL __tests__/Relude_List_test.bs.js
● List › isNotEmpty is falsefor empty list
expect(received).toBe(expected) // Object.is equality
Expected: false
Received: 0
at affirm (node_modules/@glennsl/rescript-jest/src/jest.bs.js:73:36)
at Object.<anonymous> (node_modules/@glennsl/rescript-jest/src/jest.bs.js:220:5)
● List › isNotEmpty is truefor non-empty list
expect(received).toBe(expected) // Object.is equality
Expected: true
Received: {"hd": 1, "tl": 0}
at affirm (node_modules/@glennsl/rescript-jest/src/jest.bs.js:73:36)
at Object.<anonymous> (node_modules/@glennsl/rescript-jest/src/jest.bs.js:220:5)
Thank you for filing! Check list:
Is it a bug? Usage questions should often be asked in the forum instead.
Concise, focused, friendly issue title & description.
…ean optimisations.
The pattern matching case for empty list `switch x { | list{} =>` used to compile to `if(x)`, which interferes with boolean optimisation.
Now it compiles to `if(x ==0)` which is the same output as for `if(x == list{})`.
Fixes#7235
…ean optimisations.
The pattern matching case for empty list `switch x { | list{} =>` used to compile to `if(x)`, which interferes with boolean optimisation.
Now it compiles to `if(x ==0)` which is the same output as for `if(x == list{})`.
Fixes#7235
Uh oh!
There was an error while loading. Please reload this page.
Starting from
alpha.5
(up to the currentalpha.7
), the following code generates incorrect js output:Incorrect JS output (Playground):
Whereas
alphe.4
and before generates correctly (Playground):I found out this problem when porting
[Relude](https://github.com/dsiu/rescript-relude)
to rescript@v12. The following Jest tests fails:Thank you for filing! Check list:
The text was updated successfully, but these errors were encountered: