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

[Bug] Not handling all cases during pattern-matching in lambdas #1436

Open
AZMCode opened this issue Oct 28, 2022 · 8 comments
Open

[Bug] Not handling all cases during pattern-matching in lambdas #1436

AZMCode opened this issue Oct 28, 2022 · 8 comments

Comments

@AZMCode
Copy link

AZMCode commented Oct 28, 2022

As of now, using a non-exhaustive pattern in a lambda returns the following error message

carp: src/Qualify.hs:220:55-108: Non-exhaustive patterns in lambda

With zero indication of where the offending lambda is located in code, unlike other compile time error messages.

@scolsen scolsen added the bug label Oct 28, 2022
@scolsen
Copy link
Contributor

scolsen commented Oct 28, 2022

This is reporting a case where we actually aren't handling all possible cases in the compiler. Do you have some example code that triggered this?

@AZMCode
Copy link
Author

AZMCode commented Oct 28, 2022

Sure, let me whip up some code to reproduce it. A moment.

@AZMCode
Copy link
Author

AZMCode commented Oct 28, 2022

Crashes the carp interpreter with version 0.5.5

(reduce &(fn [(Pair x y) elm] (Pair (+ x 1) y)) (Pair 0 0) &(Array.repeat 16 &(fn[] ())))

Not sure if it's possible to reduce this example even further

@AZMCode AZMCode changed the title [Feat] Improve compile error reporting for patterns matching in lambdas [Bug] Not handling all pattern during pattern-matching in lambdas Oct 28, 2022
@AZMCode AZMCode changed the title [Bug] Not handling all pattern during pattern-matching in lambdas [Bug] Not handling all cases during pattern-matching in lambdas Oct 28, 2022
@scolsen
Copy link
Contributor

scolsen commented Oct 28, 2022

Thanks a ton, @AZMCode! I'll take a look and see if I can get a fix in the next day or two.

@AZMCode
Copy link
Author

AZMCode commented Oct 28, 2022

Thank you for taking the time.

@AZMCode
Copy link
Author

AZMCode commented Jul 11, 2023

After a long time not using the language, I came back to it for funsies, stumbled upon this bug again, and decided to reduce the code further. Here's an updated example that triggers the exact same bug:

(def f (fn [ (Unit) ] ()))

@AZMCode
Copy link
Author

AZMCode commented Jul 11, 2023

I don't know if this code is valid at all, but it surely shouldn't crash the interpreter/compiler

@scolsen
Copy link
Contributor

scolsen commented Nov 15, 2023

This short repo case is great to have, thank you @AZMCode! I am hoping to spend some more time on Carp again soon and can try to fix this.

(wound up getting busy with other things as usual, after pledging to work on this before, but it is still on my radar!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants