Patch to first-class function transformer#404
Hidden character warning
Conversation
How do you know this? In the future, the runtime will also be compiled with lambda transformation, as that's how we'll compile to WASM. So ideally, we should have a proper solution to this problem. Don't we have the correct symbol, here? |
Isn't that a bug? |
No, we don't have symbols here. protected final def sel(p: Term, k: Ident): Term.SynthSel =
(Term.SynthSel(p, k)(N, N): Term.SynthSel).resolve // the first `N` indicates the symbol
lazy val unreachableFn =
Select(Value.Ref(State.runtimeSymbol), Tree.Ident("unreachable"))(N) |
No. The actual case is: when writing Foo1 = function Foo(x) {
return globalThis.Object.freeze(new Foo.class(x));
};and the |
The correct fix is to put the symbol there, not to special-case the handling of some symbols in core compiler logic... |
No, this isn't referring to the construction function. It should be referring to the class. Can you please try to fix it? By the way, are you running your pass before or after resolution? The latter would make more sense. |
The information is correct. I just need to retrieve it from the
After. Other problems are addressed (except for the unexpected failing in CI). |
I checked, and the base reference is to the BMS of the class, not to the "construction function". The BMS represents an overloaded definition, which includes both a term (the function term) and a class. The fact that the JS backend compiles the class as a member of the function is irrelevant and has no manifestation in the IR, so I think you were just confused about the semantics of BMSs. |
Yeah, working on fixing it now. |
hkmc2/shared/src/main/scala/hkmc2/codegen/FirstClassFunctionTransformer.scala
Outdated
Show resolved
Hide resolved
|
Please fix the conflict. |
A patch to #387.
When calling a function defined inruntime.mlsorglobalThis, there is no need to throw an exception (due to the lack of symbol information), since we know calling such a function does not need to use thefunc.callform.When handlingclass Foo(x); new Foo(x), there is no need to check the path of the instantiation, since it is not a call. The term symbol ofFoo.classhas a kindsyntax.Fun, which will break the transformation.disambsymbol to avoid transforming class construction unexpectedly