Skip to content

compiler crashes if :erlang.or/2 in guard #10449

@marianoguerra

Description

@marianoguerra

Precheck

  • Do not use the issue tracker for help or support (try Elixir Forum, Stack Overflow, IRC, etc.)
  • For proposing a new feature, please start a discussion on the Elixir Core mailing list: https://groups.google.com/group/elixir-lang-core
  • For bugs, do a quick search and make sure the bug has not yet been reported
  • Please disclose security vulnerabilities privately at elixir-security@googlegroups.com
  • Finally, be nice and have fun!

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.10.4 (compiled with Erlang/OTP 23)
  • Operating system:

Current behavior

The following module crashes the compiler:

defmodule MyMod do
  def fun(a) when :erlang.or(a == 1, a == 2) do
	a
  end
end

Part of the crash:

** (EXIT from #PID<0.95.0>) an exception was raised:
    ** (KeyError) key {:or, 2} not found in: ....
        (elixir 1.10.4) lib/module/types/pattern.ex:579: Module.Types.Pattern.guard_signature

Expected behavior

A compile error saying that the guard is invalid.

Like my previous reports, the code is automatically transpiled from erlang, I don't expect anyone to write this kind of code, just in case the fix may be useful in other cases, feel free to close as invalid :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions