Skip to content

Conversation

@wojtekmach
Copy link
Member

@wojtekmach wojtekmach commented Feb 19, 2021

Ref: erlang/otp#2890

On OTP 24:

iex> <<x::float-16>> = <<60, 0>>
iex> x
1.0
iex> <<x::float-16>>
<<60, 0>>

iex> <<1.0::float-128>>
** (CompileError) iex:1: float requires size*unit to be 16, 32, or 64 (default), got: 128

Before OTP 24:

iex> <<x::float-16>> = <<60, 0>>
** (CompileError) iex:1: float requires size*unit to be 32 or 64 (default), got: 16

iex> <<1.0::float-16>>
** (CompileError) iex:1: float requires size*unit to be 32 or 64 (default), got: 16

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
@josevalim josevalim merged commit b17d3a6 into elixir-lang:master Feb 20, 2021
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@wojtekmach wojtekmach deleted the wm-float-16 branch February 20, 2021 10:25
wojtekmach added a commit to wojtekmach/elixir that referenced this pull request Feb 20, 2021
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
josevalim pushed a commit that referenced this pull request Feb 20, 2021
* Update Erlang warnings translation (#10694)

Since erlang/otp@8ecc648
instead of `{eval_failure, Reason}` we'd get `{eval_failure, Call, Reason}`

* Fix translating erl compiler errors to diagnostics on OTP 24 (#10719)

The compiler previously emitted just `line` and now emits `{line,
column}`.

The diagnostic struct accepts as position either:

    nil
    line
    {start_line, start_col, end_line, end_col}

so we could have used the `column` to create the 4-tuple but we don't
have enough information to do that correctly, we don't know where the
line ends.

* Fix remaining warning translations for OTP 24 (#10720)

Yecc error message changed so we need to loosen up our assertion:

OTP 23

    iex> iex
    Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

    Interactive Elixir (1.11.3) - press Ctrl+C to exit (type h() ENTER for help)
    iex(1)> :yecc.file('f.yrl')
    f.yrl:1: syntax error before: '.'
    :error

OTP 24

    iex> iex
    Erlang/OTP 24 [DEVELOPMENT] [erts-11.1.7] [source-802d2c5083] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

    Interactive Elixir (1.12.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
    iex(1)> :yecc.file('f.yrl')
    f.yrl:1:5: syntax error before: .

    :error

* 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

* Handle :compile.file/2 returning :error on OTP 24 (#10742)

Before OTP 24 when given invalid args, :compile.file/2 would return:

    iex(1)> :compile.file('a.erl', [{:d, 'foo', 'bar'}, :report])
    {:error, :badarg}

On OTP 24:

    iex(1)> :compile.file('a.erl', [{:d, 'foo', 'bar'}, :report])

    *** Internal compiler error ***
    exception error: bad argument
      in function  io_lib:format/2
         called as io_lib:format("badly formed '~s'",[{"foo","bar"}])
      in call from sys_messages:list_errors/3 (sys_messages.erl, line 53)
      in call from lists:foreach/2 (lists.erl, line 1342)
      in call from compile:comp_ret_err/1 (compile.erl, line 546)
      in call from compile:'-internal_fun/2-anonymous-0-'/2 (compile.erl, line 229)
      in call from compile:'-do_compile/2-anonymous-0-'/1 (compile.erl, line 219)
    :error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants