Wojtek Mach
b17d3a6cca
Support 16bit floats in bitstrings ( #10740 )
...
On OTP 24:
iex> <<x::float-16>> = <<60, 0>>
iex> x
1.0
iex> <<x::float-16>>
<<60, 0>>
Before OTP 24 we'd get errors or wouldn't match:
iex> <<1.0::float-16>>
** (ArgumentError) argument error while evaluating iex at line 1
<<x::float-16>> = <<60, 0>>
** (MatchError) no match of right hand side value: <<60, 0>>
iex> (fn <<x::float-16>> -> x; _ -> :nomatch end).(<<60, 0>>)
:nomatch
2021-02-20 11:24:58 +01:00
José Valim
3d3e233255
Refactor binary handling
2020-04-05 20:15:50 +02:00
José Valim
68ad287a58
Improve error message for nested binaries in match without specifiers, closes #9908
2020-04-04 12:35:46 +02:00
José Valim
413f608ed4
Do not show binary types if they are inferred
2020-02-23 10:26:11 +01:00
Eric Meadows-Jönsson
0f85b397da
Add checking of patterns in body ( #9828 )
2020-02-20 16:46:06 +01:00
José Valim
216bf94577
Do not expand interpolation twice, closes #9709
2020-01-12 17:19:50 +01:00
José Valim
2b05b8dcf3
Use version metadata in Erlang pass
2019-11-16 02:45:55 +01:00
José Valim
123eb4e6d2
Only transform environment in match if necessary
2019-10-29 17:17:53 +01:00
José Valim
60a472e1ae
Further optimize variable merging
2019-10-29 17:17:53 +01:00
José Valim
9529e528cc
Move unused_vars to its own variable
2019-10-29 17:17:53 +01:00
José Valim
a3b1ba5a44
Remove a need to merge unused vars
2019-10-29 17:17:53 +01:00
José Valim
6c5ad7b661
Clean up Macro.Env and hide private fields
2019-07-25 22:07:51 +02:00
José Valim
59fcce0b92
Unify error handling and compiler deadlock checking ( #9009 )
2019-05-02 16:27:13 +02:00
Fernando Tapia Rico
861ba87db4
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
3e673ac134
Ensure we support counters in bitstring size vars
2019-01-07 22:31:31 +01:00
Fernando Tapia Rico
7ad213b289
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
616263f9de
Expand operands in size*unit bitstring modifier ( #8375 )
2018-11-08 19:42:55 +01:00
Glauber Campinho
495d1646b2
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
4f84f1bf2f
Ensure Macro.expand/2 does not change the meaning of interpolations
2018-08-11 20:42:24 +02:00
Tan Jay Jun
103502354c
Fix error typo in elixir_bitstring.erl ( #8030 )
...
[ci skip]
2018-08-02 15:02:17 +02:00
Aleksei Magusev
fa1191be8a
Handle nested bitstring pattern matching failures in a better way ( #7370 )
2018-02-20 23:43:14 +01:00
José Valim
00c7a3bc60
Merge binaries and bitstrings when possible
2018-01-25 15:40:44 -02:00
José Valim
83e6546f85
Perform merging of bitstring subinaries
2018-01-25 09:25:09 -02:00
José Valim
219c6cc867
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
239db307a2
Merge match_vars and prematch_vars
2018-01-20 19:42:08 +01:00
José Valim
f99bb7c0e5
Process variable versioning on Elixir pass
2018-01-20 19:42:08 +01:00
Ivan Kozik
b9ca29768a
Fix a few spelling errors ( #6525 )
2017-09-01 10:17:57 +02:00
Glauber Campinho
7951cb6a8c
Do not crash for unknown var inside binary pattern in match ( #6459 )
2017-08-15 11:53:19 +02:00
José Valim
64efa0ac69
Do not raise when expanding dynamic size
2017-04-16 17:30:46 +02:00
José Valim
8418666d84
Fix bootstraping of elixir_bitstring
2017-03-05 18:42:38 +01:00
José Valim
ba24a2fef8
Inline binaries inside interpolation
2017-03-05 18:10:11 +01:00
José Valim
c08aa189b1
Do not require size for bound literals
2017-02-24 00:38:59 +01:00
José Valim
5d6961fd92
Check for float size on elixir_bitstring
2017-02-24 00:29:01 +01:00
José Valim
4e0b33a43a
Check for binary size in bitstring matches
2017-02-24 00:29:01 +01:00
José Valim
99892760de
Split bitstring logic into proper modules
2017-02-23 23:53:12 +01:00
José Valim
d84eadb45f
Improve checking of bitstrings
2017-02-23 22:55:35 +01:00
Aleksei Magusev
84b67b5b95
Rename elixir_exp module to elixir_expand
2017-02-19 21:57:50 +01:00
Aleksei Magusev
a729847db6
Rename m/2 helper macro to key/2 in the main header file
2017-02-19 21:56:05 +01:00
José Valim
ff8dd1af7f
More module renaming and organizing
2017-02-19 21:20:43 +01:00
José Valim
e7e0d512ff
Move erlang modules to new erl namespace
2017-02-19 20:20:59 +01:00
Andrea Leopardi
068c539497
Replace compile_error/4 with form_error/4 in elixir_bitstring ( #5788 )
2017-02-18 17:29:04 +01:00
Andrea Leopardi
1cf41aeae8
Validate type for literal binaries in <<>> during expansion ( #5786 )
2017-02-18 11:58:36 +01:00
Andrea Leopardi
d814555c34
Raise for invalid literals in <<>> during expansion ( #5785 )
2017-02-18 10:51:51 +01:00
Andrea Leopardi
604c24dd2e
Raise for size() with literal binaries in <<>> during expansion ( #5783 )
2017-02-17 23:16:42 +01:00
Pedro Medeiros
0d2870f050
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
3c68af7ce3
Properly splice binaries inside binaries
2016-08-09 01:38:01 +02:00
José Valim
78c7ddc03f
Simplify type splicing for binaries
2016-07-16 20:31:03 +02:00
eksperimental
4ceb41e71b
Formmating: Add white space around vertical bar ( #4507 )
2016-04-25 00:55:49 +02:00
José Valim
3ccd5137ef
Add generated annotations
2015-10-11 12:02:47 -05:00
Aleksei Magusev
17b3df271d
Fix bitstring splicing for bytes type modifier
2015-10-07 00:30:41 +02:00