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

Mutable top-level variables become immutable #399

Open
Booksbaum opened this issue Mar 28, 2021 · 0 comments
Open

Mutable top-level variables become immutable #399

Booksbaum opened this issue Mar 28, 2021 · 0 comments

Comments

@Booksbaum
Copy link
Contributor

Mutable variables in modules and namespaces (#393) were fixed in #398, but for top-level variables that issue still remains:

export var v: number;
export let l: number;

==>

let [<Import("v","...")>] v: float = jsNative
let [<Import("l","...")>] l: float = jsNative

It should be

let [<Import("v","...")>] mutable v: float = jsNative
let [<Import("l","...")>] mutable l: float = jsNative

BUT: ts2fable places everything in a recursive module:

module rec Name
open System
//...
let [<Import(...)>] mutable v: float = jsNative

In a rec module, mutable let bindings aren't allowed:

error FS0874: Mutable 'let' bindings can't be recursive or defined in recursive modules or namespaces

-> requires a bigger rewrite than #393/#398 -- and a bigger change of generated code for top-level variables.



(extra issue for better tracking -- and #393 doesn't mention top-level variables (only tried while testing the fix))
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

No branches or pull requests

1 participant