Giter Club home page Giter Club logo

Comments (23)

Enn3Developer avatar Enn3Developer commented on June 2, 2024

I think that's something that may cause a behavior unexpected by some developers, maybe enforcing a complete match like Rust would do but that needs the type system

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

Maybe in the future, but since this is quite an issue we should fix it in 3.3 (maybe...)
An easy solution is to set _internal0 to nil using an else at the end, but should we?

from clue.

Enn3Developer avatar Enn3Developer commented on June 2, 2024

That may be the right solution for now, but probably will break compatibility with 4.0 (if a better match will be implemented, but that's not so much a problem)

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

The main worry I have is that it technically could break compatibility with 3.2 as well, since some code may actually rely on this bug

from clue.

Enn3Developer avatar Enn3Developer commented on June 2, 2024

It was never documented to do such a thing so I'd say that's better changing than not

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

Hm, true, we should fix it then yeah

from clue.

Markos-Th09 avatar Markos-Th09 commented on June 2, 2024

Since not this is intended behavior and is considered a bug we can fix it. I would say just set it to nil if nothing matches with an else block

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

I think you meant to say "Since this is not intended behaviour"?

from clue.

metamorphix avatar metamorphix commented on June 2, 2024

Absolutely agree that if no cases match, the expression should evaluate to nil. Of all things that could happen, having it evaluate to the scrutinee probably has the highest "WTF" factor!

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

Yeah it confused me a lot when I discovered it

from clue.

metamorphix avatar metamorphix commented on June 2, 2024

As for implementation, I imagine it shouldn't be too difficult as it is equivalent to there being an implicit:

_ => nil,

…at the end of every match block.

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

I think it should be easy enough to do, but I'm not sure.

from clue.

Markos-Th09 avatar Markos-Th09 commented on June 2, 2024

I think it should be easy enough to do, but I'm not sure.

probably clue should maybe print a warning about this

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

a...warning?

from clue.

Markos-Th09 avatar Markos-Th09 commented on June 2, 2024

at least if I made a linter it would be a warning, but to the context of only the compiler I guess it wouldn't be required

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

It should be best to just fix it altogether by setting it to nil, I think

from clue.

Markos-Th09 avatar Markos-Th09 commented on June 2, 2024

It should be best to just fix it altogether by setting it to nil, I think

It should be fixed but using this is sort of bad code

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

Clue never complains about bad code anywhere else, so...

from clue.

Markos-Th09 avatar Markos-Th09 commented on June 2, 2024

Clue never complains about bad code anywhere else, so...

on this should we make a linter for 4.0?

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

I think 4.0 is already a daunting task as is, maybe later on..

from clue.

metamorphix avatar metamorphix commented on June 2, 2024

You could have a warning for cases where the user is clearly doing something that doesn't make sense (like the example in the original post), but it's more commonly going to happen accidentally. What's the use case for matching on a constant? If you're matching on a variable, then without a type system, you're not going to know if the match could fail.

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

having the fail be shown by returning the matched variable also doesn't help

from clue.

Maiori44 avatar Maiori44 commented on June 2, 2024

This issue has now been fixed.

from clue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.