Skip to content

Improve error message when variables are undefined #3985

@rs86

Description

@rs86

If I try to use an undefined variable, the compiler will give out an error saying there is no function/0 defined. It is trying to parse the variable as a 0-arity function.

== Compilation error on file lib/x.ex ==
** (CompileError) lib/x.ex:36: function somevariable/0 undefined
(stdlib) lists.erl:1337: :lists.foreach/2
(stdlib) erl_eval.erl:669: :erl_eval.do_apply/6

This makes the programmer think at first that there is a problem with a function.

Is there any way to give a friendlier error message? Suggestion: if the compiler can't find a null-arity function, add to the message:

"This might be an undefined variable called xxxx".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions