digego / extempore

A cyber-physical programming environment
1.41k stars 127 forks source link

cast does not complain when casting to generics #215

Open mrmagooey opened 8 years ago

mrmagooey commented 8 years ago

cast currently does not complain when casting to a generic (even though that operation doesn't make any sense). For example this should not compile:

(bind-func get_children:[List*,Tree*]*
 "Get all children of the tree"
 (lambda (tree)
   (let ((children_list (tref tree 2)))
     (cast children_list List)
     )))

This function should actually be (where the type being casted to is a concrete type):

(bind-func get_children:[List*,Tree*]*
 "Get all children of the tree"
 (lambda (tree)
   (let ((children_list (tref tree 2)))
     (cast children_list List{Tree*}*)
     )))

Extempore's behaviour after casting to a generic is rather unpredictable, either complaining about types or going into an infinite loop.

Thanks to @benswift for identifying this.