Issue Details (XML | Word | Printable)

Key: BOO-943
Type: Wish Wish
Status: Open Open
Priority: Minor Minor
Assignee: Cedric Vivier
Reporter: Cedric Vivier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Implicit downcast should warn when used in a assignment expression

Created: 13/Jan/08 05:41 PM   Updated: 20/May/08 09:09 AM
Component/s: Compiler, Emitter
Affects Version/s: 0.8
Fix Version/s: 0.8.3

Time Tracking:
Not Specified

Testcase included: yes


 Description  « Hide
Testcase :

names as (string) = ("titi", "toto", 1,)

This compiles, and throws a InvalidCastException at run-time.

Reported by Marc Dassonneville.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Daniel Grunwald added a comment - 14/Jan/08 04:15 AM
This is not a bug.

Your code is equivalent to:
array1 as (object) = ("titi", "toto", 1,)
names as (string) = array1

This is a valid implicit cast, just like:
o1 as object = 1
name as string = o1

Although I would prefer if downcasts weren't implicit.


Cedric Vivier added a comment - 14/Jan/08 04:44 AM - edited
True.

Actually you made me remember we have had some discussion about this on the list some time ago :

http://groups.google.com/group/boolang/browse_thread/thread/6ca52fca357c4b37

The downcast is by design, however there is still the option of a gentle booc warning about this, after looking at the discussion again maybe we could emit the warning only when the implicit cast occurs in a assignment expression in order to keep the "Dispatch example" Rodrigo pointed out in the discussion to compile without warning.

What do you think?