#Rust pattern matching has one annoying flaw. All unknown identifiers in pattern matching implicitly create new variables. This behavior has caused severe bugs in my projects for the second time. I would prefer if Rust allows using a particular keyword (e.g., `let`) when a new variable is declared in the pattern matching. https://github.com/functionalscript/nanvm/pull/76/files#diff-9cba9f0ab4da950b4f2bb1396d228f3279b0615a8cba3556158e995b0bc83489
Conversation
Notices
-
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Wednesday, 17-Jan-2024 20:33:16 JST Sergey on FunctionalScript -
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Wednesday, 17-Jan-2024 22:15:57 JST Sergey on FunctionalScript @laund Sure, I would love to discuss it. But firstly, I have two questions: 1. What does the program print? 2. Does the unit test pass? https://github.com/sergey-shandar/public/blob/main/pm/src/main.rs
In conversation permalink Attachments
-
Embed this notice
laund (laund@hachyderm.io)'s status on Wednesday, 17-Jan-2024 22:15:58 JST laund @functionalscript could you elaborate some more? even looking at the PR i can't figure out what behaviour you are referring to and how it would cause issues.
In conversation permalink -
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Wednesday, 17-Jan-2024 22:25:59 JST Sergey on FunctionalScript @laund that's right! What about this version? https://github.com/sergey-shandar/public/blob/9f1e2b49a15e8f0002eb3a7292ccd1ef79381245/pm/src/main.rs
In conversation permalink Attachments
-
Embed this notice
laund (laund@hachyderm.io)'s status on Wednesday, 17-Jan-2024 22:26:00 JST laund @functionalscript it prints "5 is not the answer" and the test panics with that same message
In conversation permalink -
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Wednesday, 17-Jan-2024 22:38:51 JST Sergey on FunctionalScript @laund I think it's a feature, not a bug. If Rust can find an object with the name then it will use it instead of declaring a new one. I wish Rust has something like `let ANSWER_TO_QUESTION => ...` to make sure that we would like to create a new object.
In conversation permalink -
Embed this notice
laund (laund@hachyderm.io)'s status on Wednesday, 17-Jan-2024 22:38:52 JST laund @functionalscript thats gotta be a bug. it even panics as 42 in the test just above the match.
In conversation permalink -
Embed this notice
laund (laund@hachyderm.io)'s status on Wednesday, 17-Jan-2024 22:38:53 JST laund @functionalscript what the FUCK?
In conversation permalink
-
Embed this notice