-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: Improve error messages for using a function with wrong arity
When a function is used with wrong arity, the compiler will try to suggest all defined functions with the same name but different arities. For example, given the following module: -module(typos). -export([t/0]). bar(A) -> A. bar(A,A,A) -> A. bar(A,A,A,A) -> A. t() -> bar(0, 0). The compiler will emit the following message: typo.erl:6:12: function bar/2 undefined, did you mean bar/1,3,4? % 6| t() -> bar(0, 0). % | ^ Error types that are extended by this change: `bad_inline`, `undefined_nif`, `bad_nowarn_unused_function`, `bad_nowarn_bif_clash`, `undefined_function`. Using a function with wrong arity has higher precedence than having a typo in the function name. If the compiler can find a defined function with the same name but a different arity, it will not suggest a defined function with a close-enough name, regardless of arity.
- Loading branch information
Showing
2 changed files
with
85 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters