-
Notifications
You must be signed in to change notification settings - Fork 301
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
Simple trait calls not working properly #2135
Comments
I'm getting compiler warnings when compiling these examples in .NET. For example, when compiling the second one:
Would it be possible to get a sample that doesn't generate compiler warnings? |
Those warnings are not a big deal, if you want to get rid of them, just make them independent functions, here's how:
|
Thanks @gusty! With latest Fable build this code seems to compile correctly and doesn't generate errors as in the Fable 2 repl. I get the same result as in .NET ( export class First$1 extends Union {
constructor(tag, ...fields) {
super();
this.tag = (tag | 0);
this.fields = fields;
}
cases() {
return ["First"];
}
}
export function First$1$reflection(gen0) {
return union_type("QuickTest.First`1", [gen0], First$1, () => [[["Item", option_type(gen0)]]]);
}
export function First$1_get_Zero() {
return new First$1(0, void 0);
}
export function First_run(_arg1) {
const a = _arg1.fields[0];
return a;
}
export class Const$2 extends Union {
constructor(tag, ...fields) {
super();
this.tag = (tag | 0);
this.fields = fields;
}
cases() {
return ["Const"];
}
}
export function Const$2$reflection(gen0, gen1) {
return union_type("QuickTest.Const`2", [gen0, gen1], Const$2, () => [[["Item", gen0]]]);
}
export function Const_run(_arg1) {
const a = _arg1.fields[0];
return a;
}
export const t2 = (() => {
let arg00$0040_1;
let arg00$0040;
arg00$0040 = (new Const$2(0, First$1_get_Zero()));
arg00$0040_1 = Const_run(arg00$0040);
return First_run(arg00$0040_1);
})();
(function () {
const clo1 = toConsole(printf("t2 %A"));
clo1(t2);
})(); |
Yes, but this is an over simplified fragment of F#+ lensing. |
The first sample compiles now. I don't know if the produced JS is correct. The second sample produces a different JS output than initially reported. |
Regarding the second sample, its first version (the one with the warnings) still doesn't work (Fable 3.2.6), it doesn't print anything. |
Here's two small repros. The former produces a compile error and the latter a runtime error.
Uncommenting the
<|
operator solves the issue, no need to mention that this is not necessary in normal F#.Of course, exchanging the problematic line with the following non-trait call also makes it work, but that's not interesting.
The next fragment comes from this issue in the repl fable-compiler/repl#117
Here the situation is worst, as you can see in the linked issue it compiles fine but creates the wrong js code.
The text was updated successfully, but these errors were encountered: