Wiki

Ticket #284 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

No exception for insufficient multi-variable assignments in lists and arrays

Reported by: jaegs Owned by:
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: multi-target assignment Cc:

Description

As expected this throws an exception

a,b = 1,2,3 #error: The number of targets (2) must be the same as the number of expressions (3) assigned to them

This is not true for Lists and Arrays

a,b = [1,2,3] # a=1, b=2
c,d =  @[1,2,3] # c=1, d=2

No exception. The 3rd element is silently ignored. This is also inconsistent with Python.

a,b = [1,2,3] #ValueError: too many values to unpack

Change History

Changed 5 years ago by jaegs

  • summary changed from No exception for bad multi-target assignments in lists and arrays to No exception for insufficient multi-variable assignments in lists and arrays

Changed 5 years ago by jaegs

Cobra svn:2738 (post 0.8) / 2012-07-08 on Mono 2.10.9 CLR v4.0.30319 on Mac OS X 10.6.8

Changed 5 years ago by Charles

Working on this.

Changed 5 years ago by Charles

  • status changed from new to closed
  • resolution set to fixed

Fixed in changeset:2746

Note: See TracTickets for help on using tickets.