Closed domesticmouse closed 3 weeks ago
Summary: The user is attempting to install a Dart function into the global JS namespace using dart:js_interop
, but the function is being optimized away by the Dart compiler. The issue occurs when the function is not used after being assigned to the global variable, leading to the compiler removing the assignment.
Duplicate of https://github.com/dart-lang/sdk/issues/56533
This should be fixed in 3.6.
Duplicate of #56533
This should be fixed in 3.6.
Confirmed as working on main
I'm attempting to install a Dart function into the global JS namespace using the new
dart:js_interop
tooling, but I'm hitting an error condition.The following code fails to work as intended.
However, the following code works as intended.
Note: the only change between the two code samples is the call to
print(calculate);
.I'm guessing there is an over eager optimizer pass killing the variable store to
calculate
because said variable is never read from for the rest of the Dartmain
function.The compilation command I am using is:
And, the obligatory Flutter Doctor output: