Play

Check-in [9353390979]
Login
Overview
Comment:Fix bug where type checker would infer a nested union as possible input type. Unions are flattened.
Timelines: family | ancestors | descendants | both | stdlib
Files: files | file ages | folders
SHA3-256: 93533909798696821d86d7109d6e5024a6e1232eeadd36ed3dafb428047f7127
User & Date: robin.hansen on 2021-04-15 09:32:30
Other Links: branch diff | manifest | tags
Context
2021-04-15
09:55
Fix bug where type checker would remove generic from inferred output of a multi-function, if the sam... check-in: aee83f3ef4 user: robin.hansen tags: stdlib
09:32
Fix bug where type checker would infer a nested union as possible input type. Unions are flattened. check-in: 9353390979 user: robin.hansen tags: stdlib
2021-04-13
13:58
Instead of inferring types of each branch in a multi-fn and compare the results to type annotation, ... check-in: 76d7054f19 user: robin.hansen tags: stdlib
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Play/TypeChecker.elm from [bbcfdae6cb] to [d9536ea640].

548
549
550
551
552
553
554

555
556








557
558
559
560
561
562
563

unionOfTypeMatches : List ( Qualifier.TypeMatch, a ) -> Type
unionOfTypeMatches whenBranches =
    let
        uniqueTypes =
            whenBranches
                |> List.map (Tuple.first >> extractTypeFromTypeMatch)

                |> List.gatherEquals
                |> List.map Tuple.first








    in
    case uniqueTypes of
        [ singleType ] ->
            singleType

        _ ->
            Type.Union uniqueTypes







>


>
>
>
>
>
>
>
>







548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572

unionOfTypeMatches : List ( Qualifier.TypeMatch, a ) -> Type
unionOfTypeMatches whenBranches =
    let
        uniqueTypes =
            whenBranches
                |> List.map (Tuple.first >> extractTypeFromTypeMatch)
                |> List.concatMap flattenUnions
                |> List.gatherEquals
                |> List.map Tuple.first

        flattenUnions t =
            case t of
                Type.Union members ->
                    List.concatMap flattenUnions members

                _ ->
                    [ t ]
    in
    case uniqueTypes of
        [ singleType ] ->
            singleType

        _ ->
            Type.Union uniqueTypes