Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Structural pattern matching should still work with intersection types #12142

Open
radeusgd opened this issue Jan 24, 2025 · 1 comment
Open
Assignees
Labels

Comments

@radeusgd
Copy link
Member

In a18214f I've added 2 tests regarding structural pattern matching, based on issues encountered in #12120.

They are following:

group_builder.specify "structural pattern matching should be able to match the primary type" <|
    ab = make_a_and_b
    r = case ab of
        A.A_Ctor x -> "matched: "+x.to_text
        _ -> "structural matching of A.A_Ctor failed"
    r.should_equal "matched: 1"

group_builder.specify "should structural matching match other types?" <|
    ab = make_a_and_b
    r = case ab of
        B.B_Ctor x -> "matched: "+x.to_text
        _ -> "structural matching of B.B_Ctor failed"
    r.should_equal "matched: (A_Ctor 1)"

In my opinion the first test should surely pass - if the value is A with some extra B intersections, it should not only match _:A but also the 'structural' matching.

As for the second test - I don't have a strong opinion, although I think that if a type is both A & B then it should probably match the B part structurally too (of course as long as the constructor also matches, if B type had more than 1 constructor).

@radeusgd
Copy link
Member Author

Currently the above tests are failing with

    - [FAILED] structural pattern matching should be able to match the primary type [42ms]
        Reason: 'structural matching of A.A_Ctor failed' did not equal 'matched: 1' (at Base_Tests\src\Semantic\Multi_Value_As_Type_Refinement_Spec.enso:175:13-39).


    - [FAILED] should structural matching match other types? [7ms]
        Reason: 'structural matching of B.B_Ctor failed' did not equal 'matched: (A_Ctor 1)' (at Base_Tests\src\Semantic\Multi_Value_As_Type_Refinement_Spec.enso:182:13-48).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Status: 📤 Backlog
Development

No branches or pull requests

2 participants