Wiki

Ticket #170 (closed defect: fixed)

Opened 15 years ago

Last modified 15 years ago

Multitarget assignment does not infer types of cast expressions

Reported by: Chuck Owned by: Chuck
Priority: major Milestone: Cobra 0.9
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

This program should work, but gives two errors:

class X
	def main
		a = 'aoeu' to Object
		b = 5 to Object
		x, y = a to String, b to int
		assert x.length == 4
		assert y * 2 == 10

The errors:

(6): error: Cannot find a definition for "length" in "x" whose type is "Object".
(7): error: Cannot apply STAR to Object and int. Try finding a method that performs this function.

It seems that x and y are inferred as Object instead of the types that the right hand expressions are cast to.

Attachments

multiarg-inferType-cast.patch Download (1.9 KB) - added by hopscc 15 years ago.

Change History

Changed 15 years ago by hopscc

Due to type erasure/obscuration from passing through a List.
same as

class X
	def main
		a = 'aoeu' to Object
		b = 5 to Object
		l = [a to String, b to int]
		x = l[0]
		y = l[1]
		assert x.length == 4
		assert y * 2 == 10

patch coming...
Should the above list case also be a bug ?

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

  • owner set to Chuck
  • status changed from new to assigned

patch, test and relnote note
Make cast expression one of simple expressions expanded into assignment block.

Changed 15 years ago by Chuck

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

Applied in changeset:2147

Thanks!

Note: See TracTickets for help on using tickets.