Comments (4)
It does not break any of my projects, no. I discovered this when experimenting.
from gleam.
Thank you. Does this break any of your projects?
from gleam.
FYI looks like this is the same issue as #3251 as for actually solving this, my erlang isn't great but as far as I understand from reading docs/looking online, erlang doesn't allow assignments in bitarray matches right? So we can't produce something like the below because the assignment is a syntax error. I assume we can't make this a regular compilation error since that gleam code is valid when compiled to javascript? In Javascript we make this work by doing the assignment inside the block so I guess we could try to do the same thing for this case? lmk if this sounds reasonable or if I'm totally off the mark
-module(test_gleam).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([main/0]).
-spec main() -> bitstring().
main() ->
_assert_subject = <<65>>,
<<65 = A, _/binary>> = case _assert_subject of
<<65, _/binary>> -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"test_gleam"/utf8>>,
function => <<"main"/utf8>>,
line => 2})
end.
from gleam.
Bit array patterns are so tricky! Lots of weird restrictions I didn't realise.
We could remove the 65 =
and push a guard of A =:= 65
perhaps? Seems like it could get a bit complicated.
Shall we close the other issue and track this one here? Seeing as it has more context?
from gleam.
Related Issues (20)
- Crash when adding cyclic import HOT 1
- Formatter doesn't break some lines longer than 80 characters HOT 1
- JavaScript variable redeclaration in single pattern case statement HOT 1
- LSP: auto-imports feature doesn't handle `_` well HOT 4
- module_info function name is not being escaped on erlang HOT 2
- Improve [..] syntax deprecation warning HOT 1
- Gleam version in default Github's test workflow does not match the gleam's version used to generate it HOT 3
- Can use private type in signature of public function when in a very specific directory HOT 3
- Print correct syntax for "Inexhaustive patterns" diagnostic, relative to current module
- LSP code action: import unknown module / type HOT 1
- LSP: Not starting in Neovim HOT 5
- Docs generator could show doc blocks of re-exported types just like the LSP does HOT 1
- Formatter moves doc comments around when surrounded by commented-out code HOT 2
- Formatter doesn't indent lists in cases with comments HOT 1
- gleam compiler seems confused when erlang module has the same name of gleam module HOT 2
- Function fault tolerance results in confusing errors when using labels and arity is incorrect HOT 2
- Gleam exits silently when erl doesn't work HOT 3
- Language server fails to report error when a module is renamed/removed HOT 1
- Field punning HOT 2
- [ERROR] Expected ")" but found "$" HOT 1
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 gleam.