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

Partial Fix of #401: Variables & Properties with generic type parameter #412

Merged
merged 6 commits into from
Apr 25, 2021

Conversation

Booksbaum
Copy link
Contributor

Handles only Namespaces/Modules & Interfaces/Classes (-> interface), NOT top-level variables (-> let binding).

Currently only updated for namespaces (& modules),
but not interfaces, classes, root variables

Variables are now transformed into Properties:
Variables were already emitted as F# Properties, but their handling was
different
from real Properties. Now Variables are converted into Properties in
`transform.fs`
and can use the same print code as real Properties.
Exception: Top level variables. These are printed as `let` binding,
not abstract members in an interface.

Add Generic Type Constraints for Variables and Properties
(Properties instead of variables -- but same issues for function
properties)
Add (more) tests for multiple parameter:
Strange behaviour in F#:
`abstract v: string -> string -> string` is ok,
`abstract v: string -> string -> string` isn't, but required brackets
Further with generyc type parameter:
`abstract v: 'T -> 'T -> 'T` is ok, but (unlike with just `string`)
`abstract v: ('T -> 'T -> 'T)` is not (type parameter 'T is not defined)

Add tests for optional property:
Again strange behaviour in F#:
`abstract o: 'T option` isn't allowed, but
`abstract o: 'T option with get,set` is.

Most of these cases most likely don't occur in real code.
In the source for this issue and its tests it's not a general `'T`,
but a limitation (subset) of a string Enum
There might be cases a Variable wasn't transformed into a property.
These would now fail. To prevent this Variables are now again handled in
`printType` as a fallback. Additional a log message is printed to
console.
@Booksbaum Booksbaum merged commit 5c2d3f8 into fable-compiler:master Apr 25, 2021
@Booksbaum Booksbaum deleted the variable-generic branch April 25, 2021 15:24
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 this pull request may close these issues.

1 participant