Skip to content

internal consistency check failed - bad arg type on recursive function using negative numbers and rem #11400

Description

@lmaltsis

Describe the bug

$ erlc /tmp/bug.erl
bug:1: function f/1+10:
  Internal consistency check failed - please report this bug.
  Instruction: {call_only,1,{f,4}}
  Error:       {bad_arg_type,{x,0},{t_integer,{-27,23}},{t_integer,{-26,22}}}:

To Reproduce

-module(bug).
-export([main/0]).

main() ->
        f(10).

f(N) ->
        f(((-1) rem N) - 2).

Expected behavior
Compiles and then

Affected versions
trunk: ab09c7f
seems like it is relatively new, e.g. 26.2.2 is not affected https://godbolt.org/z/oqhWbMnb1

Metadata

Metadata

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions