GithubHelp home page GithubHelp logo

Comments (4)

DanielleMaywood avatar DanielleMaywood commented on August 11, 2024 1

It does not break any of my projects, no. I discovered this when experimenting.

from gleam.

lpil avatar lpil commented on August 11, 2024

Thank you. Does this break any of your projects?

from gleam.

Acepie avatar Acepie commented on August 11, 2024

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.

lpil avatar lpil commented on August 11, 2024

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)

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.