Skip to content

Give a better error than BoundsError in multiple assignment #7978

Closed
@quinnj

Description

@quinnj

Seems like we could give a better error here:

In  [65]: a,b = 1,2

Out [65]: (1,2)

In  [66]: a,b = 1,2,3

Out [66]: (1,2,3)

In  [67]: a,b,c = 1,2

Out [67]: ERROR: BoundsError()
while loading In[67], in expression starting on line 1

This example is trivial, but a use case that was much more frustrating was along the lines of

julia> a,b,c = arrayA[x], methodB(y)

Out [67]: ERROR: BoundsError()
while loading In[67], in expression starting on line 1

In which case you spend too much time checking if x is inbounds, and then if methodB is somehow out of bounds, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    error handlingHandling of exceptions by Julia or the user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions