Skip to content
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

Unit type compiles to undeclare variable #3584

Closed
lukethenuke opened this issue Nov 7, 2023 · 0 comments · Fixed by #3587
Closed

Unit type compiles to undeclare variable #3584

lukethenuke opened this issue Nov 7, 2023 · 0 comments · Fixed by #3587

Comments

@lukethenuke
Copy link

Description

Noticed a lot of runtime errors when upgrading fable from 3.2.6 to 4.4.1.
We do code splitting using FunctionComponent.Lazy and when using an empty prop type in the component it crashes on an undeclared variable, I have extracted and reproduced a minimal sample of the bug below.

Repro code

REPL

let inline Repro(f: 'T -> string): 'T -> string =
        let unused = f
        fun a -> $"{a}"

let bad = Repro (fun (props: unit) -> "s")
let ok = Repro (fun (props: string) -> "s")
export const bad = (() => {
    const unused = () => "s";
    return () => (`${a}`);
})();

export const ok = (() => {
    const unused = (props) => "s";
    return (a) => (`${a}`);
})();

notice in bad the string interpolation contains a reference to the undeclared variable a.

Expected and actual results

I'm unsure what to expect here, but the current results looks wrong.

Related information

I have tested different versions and this seems to be the behavior in version 3.7.10 and later.
Related issue? #1832

ncave added a commit to ncave/Fable that referenced this issue Nov 12, 2023
@ncave ncave mentioned this issue Nov 12, 2023
ncave added a commit to ncave/Fable that referenced this issue Nov 14, 2023
ncave added a commit to ncave/Fable that referenced this issue Nov 14, 2023
ncave added a commit to ncave/Fable that referenced this issue Nov 15, 2023
ncave added a commit to ncave/Fable that referenced this issue Nov 15, 2023
ncave added a commit that referenced this issue Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant