otp
otp copied to clipboard
Using 'inline_list_funcs' with lists:xxx
Describe the bug lists:all(fun erlang:is_integer/1, Values) compile with inline_list_funcs
To Reproduce Warning: this clause cannot match because a previous clause always matches
Expected behavior no warning
Affected versions with 24.3.4 on WLS
Additional context see more in: https://erlangforums.com/t/using-inline-list-funcs-with-lists-xxx/1654
I suspect something strange happens in an compiler internal pass. This will have to wait until our compiler people are back from their vacation.
I have only figured out that when using fun erlang:is_integer/1
the compiler manages to inline the function call and the loop becomes only 4 .beam assembly instructions.
When using fun is_integer/1
the compiler writes a function precisely as for fun (X) -> is_integer end
, a function that just calls the BIF is_integer/1
, but the loop in this case calls the function and checks the return value so the loop becomes 10 .beam assembly instructions.
But why the faster code gets a warning is weird. I se no problem with the generated assembly code.
Affected versions with 24.3.4 on WLS
For the record, same for 25.0.3 and 23.3 on Ubuntu.
The linked pull request resolves the issue. It will be included in OTP 25.1.