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

Fix #3274 and other features #3279

Merged
merged 3 commits into from
Nov 23, 2022
Merged

Fix #3274 and other features #3279

merged 3 commits into from
Nov 23, 2022

Conversation

alfonsogarciacaro
Copy link
Member

@alfonsogarciacaro alfonsogarciacaro commented Nov 20, 2022

  1. Fix Wrong behavior if --outDir is a prefix of project dir #3274: Output files are not put into outDir when this is a prefix of the project dir
  2. Check Condition when manually parsing .fsproj in Fable packages. The condition is only evaluated if the property is one of the constants defined by Fable or user. Not sure if we will use this feature but I implemented it in case we decide to publish packages with different files for each target language.
  3. Support for ValueOption module

@alfonsogarciacaro
Copy link
Member Author

alfonsogarciacaro commented Nov 20, 2022

UPDATE: Commits concerning this and below comments have been moved to #3282

@dbrattli If you want to identify Fable.Core.U2 and friends, here's how to do it (using a regex). I haven't added yet logic for identifying all types of erased union, which would be more complex, so for now is probably to still output any or its equivalent in those cases.

@dbrattli
Copy link
Collaborator

@alfonsogarciacaro I just played with this example:

[<Erase>]
type ErasedUnion =
    | ErasedInt of int
    | ErasedString of string


let test () =
    let erased = ErasedInt 5
    ()

Which currently outputs:

def test(__unit: None=None) -> None:
    erased: ErasedUnion = 5

So I need to figure out where to translate ErasedUnion into int since the type ErasedUnion cannot be used. So is that the reason for the types not being translated correctly?

@alfonsogarciacaro
Copy link
Member Author

Yes, but it's a bit complicated because erased unions can be compiled in different ways. I will update the documentation and add a helper tomorrow so it's clearer.

@dbrattli
Copy link
Collaborator

PS: I btw managed to get U2/U3/... working with Python:

let test (arg: U2<string, int>) =
    ()

test (U2.Case2 10)
let a : U3<string, int, float> = U3.Case1 "hello"
from typing import Union

def test(arg: Union[str, int]) -> None:
    pass


test(10)

a: Union[str, int, float] = "hello"

@alfonsogarciacaro
Copy link
Member Author

Because I realized I still need to fix reflection for erased records and unions and also Rust tests, maybe this cannot make it into Fable 4 release, so I've moved the erased record/union part to #3282

@alfonsogarciacaro alfonsogarciacaro merged commit 5b806eb into main Nov 23, 2022
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.

Wrong behavior if --outDir is a prefix of project dir
2 participants