New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Seq|List).fold produces incorrect output when state is a function with arity > 1 #2035
Comments
I stepped through the generated JS. The problem seems to be here: export function folder(state$$1, value, x, y) {
return new List(value, state$$1(x, y));
}
This works: export function folder(state$$1, value, x, y) {
return new List(value, state$$1(x)(y));
} |
Yes, the problem seems to be that the F# compiler wraps the let inline folder st value x y = value :: st x y
let state x y = [x; y]
let d = List.fold folder state [0;1;2;3]
System.Console.WriteLine(List.length (d 42 42)) compiles to: import { length, fold, ofArray } from "fable-library/List.js";
import { List } from "fable-library/Types.js";
export function state(x, y) {
return ofArray([x, y]);
}
export const d = fold(function (st, value) {
return function (x$$1) {
return function (y$$1) {
return new List(value, st(x$$1, y$$1));
};
};
}, function (x$$3) {
return function (y$$3) {
return state(x$$3, y$$3);
};
}, ofArray([0, 1, 2, 3]));
console.log(length(d(42)(42))); |
alfonsogarciacaro
added a commit
that referenced
this issue
Apr 28, 2020
alfonsogarciacaro
added a commit
that referenced
this issue
Apr 29, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Seq.fold
andList.fold
produce incorrect output whenstate
is a function with arity greater than 1.Repro code
Repl link
Expected and actual results
Expected output:
[3; 2; 1; 0; 42; 42]
Actual output:
[3]
The tail of the resulting
List
is a function instead of an otherList
.Related information
The text was updated successfully, but these errors were encountered: