Closed
Description
[Google Issue #1800 : https://code.google.com/p/haxe/issues/detail?id=1800]
by heinz.ho...@googlemail.com, at 09/05/2013, 23:00:14
try to compile the following code. It fails with
Bug.hx:22: characters 23-30 : Unknown<0> should be {+ get : Void -> Unknown<0> }
Bug.hx:22: characters 23-30 : For function argument 'v'
Bug.hx:22: characters 4-8 : Void should be haxe.ds.Option<{+ get : Void -> Unknown<0> }>
package ;
import haxe.ds.Option;
using Bug.Helper;
class Helper { macro public static function get <T>(e:haxe.macro.Expr.ExprOf<T>):haxe.macro.Expr.ExprOf<T> return e; }
class Bug { static function test <T>(a:Array<T>) { var v = None; // fails // var v:Option<T> = None; // fails also for (e in a) { v = switch (v) { case Some(x): Some(x.get()); case None: Some(e); } } } static function main () { test([1,2]); } }
without type parameter it only fails when v is not explicitly typed:
static function test (a:Array<Int>) { // var v = None // fails var v:Option<T> = None; // works for (e in a) { v = switch (v) { case Some(x): Some(x.get()); case None: Some(e); } } }
Metadata
Metadata
Assignees
Labels
No labels
Activity