Comments (23)
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.
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.
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.
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.
It was never documented to do such a thing so I'd say that's better changing than not
from clue.
Hm, true, we should fix it then yeah
from clue.
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.
I think you meant to say "Since this is not intended behaviour"?
from clue.
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.
Yeah it confused me a lot when I discovered it
from clue.
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.
I think it should be easy enough to do, but I'm not sure.
from clue.
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.
a...warning?
from clue.
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.
It should be best to just fix it altogether by setting it to nil, I think
from clue.
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.
Clue never complains about bad code anywhere else, so...
from clue.
Clue never complains about bad code anywhere else, so...
on this should we make a linter for 4.0?
from clue.
I think 4.0 is already a daunting task as is, maybe later on..
from clue.
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.
having the fail be shown by returning the matched variable also doesn't help
from clue.
This issue has now been fixed.
from clue.
Related Issues (20)
- [Bug/Library bitwise mode] build_expression consumes end token in ALTER values HOT 2
- `for i in f, stop, initial` syntax HOT 1
- Commas in string `@macro` argument count as `@macro` arguments. HOT 2
- Enumerators do not work with negative numbers HOT 2
- `@define` doesn't recognize strings? HOT 2
- Using `continue` twice breaks when using the MoonScript continue mode HOT 1
- Use any whitespace in indentation of multiline regular strings HOT 5
- CLI stdin/stdout stream improvements HOT 6
- OOB Panic on specific arrangements of LuaJIT-style integer formats (LL/ULL) HOT 1
- Allow other types of keys in renameable table destructuring feature HOT 1
- `goto` statement HOT 2
- CLI improvements
- Operator precedence gets messed up when using bitwise operators on bitlib mode HOT 1
- C binding library interface for the Clue compiler
- Make parentheses optional for function calls with single parameter string/table HOT 1
- Multi-expression matching support HOT 4
- Increment operators like `x++` and `++x` HOT 1
- Commas in function that passed to `@macro` argument are treating as actual commas. HOT 2
- debug flag causes invalid escape sequence error on windows HOT 1
- Introduce constants HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clue.