Skip to content

unhelpful syntax error message when loop variable not a variable #900

@mlubin

Description

@mlubin

Put the following snippet in a file, say foo.jl, and run load("foo.jl")

function foo()
    for 1 in 1:10
        bar()
    end
end

The error printed is:

syntax error: invalid assignment lvalue 1 at foo.jl:6
 in include at /mnt/hdd/work/julia/src/boot.jl:201
at foo.jl:0
 in load at util.jl:218

Note that the line referred to is the last line of the function, not the line with the actual error. This could lead to unneeded head-banging.

[pao: title]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions