Commit Graph
59 Commits
Author SHA1 Message Date
José Valim dbf8a7a9fe Use version metadata in Erlang pass 2019-11-16 02:45:55 +01:00
José Valim c74bfa4a52 Only transform environment in match if necessary 2019-10-29 17:17:53 +01:00
José Valim 1c9b55ae6d Further optimize variable merging 2019-10-29 17:17:53 +01:00
José Valim acc9b49208 Move unused_vars to its own variable 2019-10-29 17:17:53 +01:00
José Valim 4992622be1 Remove a need to merge unused vars 2019-10-29 17:17:53 +01:00
José Valim 31e4a93bc6 Clean up Macro.Env and hide private fields 2019-07-25 22:07:51 +02:00
José Valim e80b55b21c Unify error handling and compiler deadlock checking (#9009) 2019-05-02 16:27:13 +02:00
Fernando Tapia Rico 94c0dd23d2 Ensure guard checks when expanding string interpolations (#8905)
During the bitstring expansion, guard checks were avoided due to
a special case for inlining binaries during interpolation. These
changes ensure guards are checked.
2019-03-22 11:26:02 +01:00
José Valim 4c87c902c9 Ensure we support counters in bitstring size vars 2019-01-07 22:31:31 +01:00
Fernando Tapia Rico 7104ca20fd Error on undefined variables in bitstring segments (#8598)
Binary/bitstring matching allows to dynamically define the
`size` of the binary in certain conditions:

  * if the `size` variable is defined prior to the pattern
    match:

        iex> size = 8
        iex> <<a::size(size), rest::binary>> = "hello"
        iex> a
        104

  * if the `size` variable is matched within the same
    binary/bitstring match, prior to its use:

        iex> <<name_size::size(8), name::binary-size(name_size), _rest::binary>> = <<5, "Frank the Walrus">>
        iex> name
        "Frank"

Other cases are considered illegal patterns, for example:

    {name_size, <<name::binary-size(name_size), _rest::binary>>} = {5, "Frank the Walrus"}

This commit raises a `CompileError: undefined variable ...` for such cases.
2019-01-05 17:46:33 +01:00
Wojtek Mach c0317dcd64 Expand operands in size*unit bitstring modifier (#8375) 2018-11-08 19:42:55 +01:00
Glauber Campinho 6af3110b6a Small optimization on elixir_bitstring:expand/4 (#8074)
`elixir_env:mergea(EV, EC)` is always equivalent to `EV` so we can avoid the operation.
Similar to #8069
2018-08-12 10:05:59 +02:00
José Valim 2af6e62626 Ensure Macro.expand/2 does not change the meaning of interpolations 2018-08-11 20:42:24 +02:00
Tan Jay Jun d555a7fdbc Fix error typo in elixir_bitstring.erl (#8030)
[ci skip]
2018-08-02 15:02:17 +02:00
Aleksei Magusev d1156f4161 Handle nested bitstring pattern matching failures in a better way (#7370) 2018-02-20 23:43:14 +01:00
José Valim 90cd4e7050 Merge binaries and bitstrings when possible 2018-01-25 15:40:44 -02:00
José Valim d2fb3279f1 Perform merging of bitstring subinaries 2018-01-25 09:25:09 -02:00
José Valim 9d40e110d9 Move unused_vars check to Elixir land
This gives us better control over when and how unused variables are printed.

As a result, we are able to emit unused variable warnings in situations
we could not before. This also opens up the way for us to remove a
dependency on erl_lint and track types information, which allows us to
speed up compilation times about 5% and allow us to emit more performant
code in some situations.
2018-01-20 19:45:48 +01:00
José Valim 85becb02e8 Merge match_vars and prematch_vars 2018-01-20 19:42:08 +01:00
José Valim fd4dc4474a Process variable versioning on Elixir pass 2018-01-20 19:42:08 +01:00
Ivan Kozik dbabe33349 Fix a few spelling errors (#6525) 2017-09-01 10:17:57 +02:00
Glauber Campinho 953a3b2890 Do not crash for unknown var inside binary pattern in match (#6459) 2017-08-15 11:53:19 +02:00
José Valim 7acdd4e019 Do not raise when expanding dynamic size 2017-04-16 17:30:46 +02:00
José Valim beb4ce260c Fix bootstraping of elixir_bitstring 2017-03-05 18:42:38 +01:00
José Valim 62055875ba Inline binaries inside interpolation 2017-03-05 18:10:11 +01:00
José Valim 3cb4f2d3ad Do not require size for bound literals 2017-02-24 00:38:59 +01:00
José Valim c7b06a0ddb Check for float size on elixir_bitstring 2017-02-24 00:29:01 +01:00
José Valim 7f488e16ca Check for binary size in bitstring matches 2017-02-24 00:29:01 +01:00
José Valim cdaabf1824 Split bitstring logic into proper modules 2017-02-23 23:53:12 +01:00
José Valim 98745273fb Improve checking of bitstrings 2017-02-23 22:55:35 +01:00
Aleksei Magusev 30ba2c8527 Rename elixir_exp module to elixir_expand 2017-02-19 21:57:50 +01:00
Aleksei Magusev c1c009537a Rename m/2 helper macro to key/2 in the main header file 2017-02-19 21:56:05 +01:00
José Valim a722e6c18c More module renaming and organizing 2017-02-19 21:20:43 +01:00
José Valim adb0a0f095 Move erlang modules to new erl namespace 2017-02-19 20:20:59 +01:00
Andrea Leopardi 0961b07ef2 Replace compile_error/4 with form_error/4 in elixir_bitstring (#5788) 2017-02-18 17:29:04 +01:00
Andrea Leopardi fc1ddc27b8 Validate type for literal binaries in <<>> during expansion (#5786) 2017-02-18 11:58:36 +01:00
Andrea Leopardi 264d52c2c9 Raise for invalid literals in <<>> during expansion (#5785) 2017-02-18 10:51:51 +01:00
Andrea Leopardi b4e3475a0a Raise for size() with literal binaries in <<>> during expansion (#5783) 2017-02-17 23:16:42 +01:00
Pedro Medeiros 3016cdb69b Fix some exported from case from erlang source (#5214)
Some erlang code were emiting a warning message when some
variables were defined inside the case statement.
2016-09-14 13:45:32 +02:00
José Valim e5f700d5ff Properly splice binaries inside binaries 2016-08-09 01:38:01 +02:00
José Valim 24fee6893d Simplify type splicing for binaries 2016-07-16 20:31:03 +02:00
eksperimental 685e87bdf0 Formmating: Add white space around vertical bar (#4507) 2016-04-25 00:55:49 +02:00
José Valim 913ca994f3 Add generated annotations 2015-10-11 12:02:47 -05:00
Aleksei Magusev f90eada48f Fix bitstring splicing for bytes type modifier 2015-10-07 00:30:41 +02:00
eksperimental f9bcdd5c1c Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
Aleksei Magusev 10191cd210 Use :lists.reverse/2 instead of :lists.reverse/1 and ++ 2015-02-19 22:49:36 +01:00
José Valim 0cfe5296d5 Remove deprecated code 2014-08-02 22:35:57 +02:00
José Valim ecdcfaeda1 Remove deprecated features and deprecate soft ones 2014-07-12 16:23:17 +02:00
José Valim e808d9d072 Convert existing bitstring examples to new syntax 2014-07-02 21:32:00 +02:00
José Valim 38624f2c07 New bitstring syntax, closes #1950 2014-07-02 21:19:01 +02:00