-
Notifications
You must be signed in to change notification settings - Fork 292
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
Object expression should not inline variable in getter in Release
mode
#3779
Comments
…e `ITypeScriptReader` to work around a bug in Fable See fable-compiler/Fable#3779
@MangelMaxime Perhaps I'm doing something wrong, but I cannot reproduce with v4.14, with or without import { class_type } from "../fable_modules/fable-library-js.4.14.0/Reflection.js";
import { format } from "../fable_modules/fable-library-js.4.14.0/String.js";
export class Reader {
constructor() {
}
}
export function Reader_$reflection() {
return class_type("TestApp.Reader", void 0, Reader);
}
export function Reader_$ctor() {
return new Reader();
}
export const reader = (() => {
let warnings = [];
return new (class extends Reader {
constructor() {
super();
}
"TestApp.Reader.get_Warnings"() {
return warnings;
}
}
)();
})(); Can you post your full build command line? |
@ncave Here are the steps I used to test it out:
import { class_type } from "./fable_modules/fable-library-js.4.14.0/Reflection.js";
import { printf, toConsole } from "./fable_modules/fable-library-js.4.14.0/String.js";
export class Reader {
constructor() {
}
}
export function Reader_$reflection() {
return class_type("Test.Reader", void 0, Reader);
}
export function Reader_$ctor() {
return new Reader();
}
export const reader = new (class extends Reader {
constructor() {
super();
}
"Test.Reader.get_Warnings"() {
return [];
}
}
)();
void (reader["Test.Reader.get_Warnings"]().push("Warning 1"));
void (reader["Test.Reader.get_Warnings"]().push("Warning 2"));
(function () {
const arg = reader["Test.Reader.get_Warnings"]().length | 0;
toConsole(printf("Count: %A"))(arg);
})(); The problematic lines are: "Test.Reader.get_Warnings"() {
return [];
} If you run import { class_type } from "./fable_modules/fable-library-js.4.14.0/Reflection.js";
import { printf, toConsole } from "./fable_modules/fable-library-js.4.14.0/String.js";
export class Reader {
constructor() {
}
}
export function Reader_$reflection() {
return class_type("Test.Reader", void 0, Reader);
}
export function Reader_$ctor() {
return new Reader();
}
export const reader = (() => {
const warnins = [];
return new (class extends Reader {
constructor() {
super();
}
"Test.Reader.get_Warnings"() {
return warnins;
}
}
)();
})();
void (reader["Test.Reader.get_Warnings"]().push("Warning 1"));
void (reader["Test.Reader.get_Warnings"]().push("Warning 2"));
(function () {
const arg = reader["Test.Reader.get_Warnings"]().length | 0;
toConsole(printf("Count: %A"))(arg);
})(); Which is "correct". I tested it on OSX and Linux (dev container) with Fable 4.14 instead from NuGet for both of them. |
@MangelMaxime Probably different default configurations when using a project file vs a script. In theory an array is mutable so it shouldn't be beta reduced (like other mutables or side effects), we have to see if it's the F# compiler optimizing it, or Fable. |
@ncave Here I used Here is a reproduction project: https://github.com/MangelMaxime/fable-reproduction-issue-3779 If you run Steps used to setup that repository
|
Description
In watch mode:
In build mode:
This cause a problem because, now the getter always
reset
the value ofwarnings
in build mode.Meaning that in
Release
mode we get0
instead of2
.Expected and actual results
Should returns
2
in Release mode too.Related information
The text was updated successfully, but these errors were encountered: