don't try to type-guess on list expressions in case
This commit is contained in:
@@ -102,6 +102,7 @@ class FieldForms {
|
||||
var access = fieldAccess(formName, name, args[0]);
|
||||
|
||||
var type = Helpers.explicitType(args[0]);
|
||||
if (type != null)
|
||||
k.typeHints.push({name: name, type: type});
|
||||
|
||||
({
|
||||
|
||||
@@ -173,7 +173,7 @@ class Helpers {
|
||||
};
|
||||
}
|
||||
|
||||
var args = switch (argList.def) {
|
||||
var args:Array<FunctionArg> = switch (argList.def) {
|
||||
case ListExp(funcArgs):
|
||||
funcArgs.map(makeFuncArg);
|
||||
case CallExp(_, _):
|
||||
@@ -190,6 +190,7 @@ class Helpers {
|
||||
}];
|
||||
|
||||
for (v in vars) {
|
||||
if (v.type != null)
|
||||
k.typeHints.push(v);
|
||||
}
|
||||
|
||||
@@ -206,6 +207,7 @@ class Helpers {
|
||||
}
|
||||
|
||||
for (v in vars) {
|
||||
if (v.type != null)
|
||||
k.typeHints.remove(v);
|
||||
}
|
||||
|
||||
@@ -217,7 +219,7 @@ class Helpers {
|
||||
ret: if (name != null) Helpers.explicitType(name) else null,
|
||||
args: args,
|
||||
expr: expr
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// The name of this function is confusing--it actually makes a Haxe `case` expression, not a switch-case expression
|
||||
|
||||
@@ -204,6 +204,7 @@ class SpecialForms {
|
||||
}
|
||||
|
||||
for (v in varDefs) {
|
||||
if (v.type != null)
|
||||
k.typeHints.push(v);
|
||||
}
|
||||
|
||||
@@ -213,6 +214,7 @@ class SpecialForms {
|
||||
]).withMacroPosOf(wholeExp);
|
||||
|
||||
for (v in varDefs) {
|
||||
if (v.type != null)
|
||||
k.typeHints.remove(v);
|
||||
}
|
||||
|
||||
@@ -322,8 +324,16 @@ class SpecialForms {
|
||||
|
||||
// On C#, C++, and HashLink, value types (specifically Float and Int) cannot be null, so they cannot be compared with null.
|
||||
// Therefore a null case doesn't need to be added--and will cause a compile failure if it is.
|
||||
var canCompareNull = if (Context.defined('cs') || Context.defined('cpp') || Context.defined('hl')) {
|
||||
switch (exp.typeof(k.typeHints)) {
|
||||
var canCompareNull = switch (args[0].def) {
|
||||
// don't try to type [multiple caseArgs]! It will never return!
|
||||
case ListExp(_):
|
||||
false;
|
||||
default:
|
||||
if (Context.defined('cs') || Context.defined('cpp') || Context.defined('hl')) {
|
||||
var type = exp.typeof(k.typeHints);
|
||||
switch (type) {
|
||||
case null:
|
||||
false;
|
||||
case Success(TAbstract(ref, [])) if (["Int", "Float", "Bool"].indexOf(ref.get().name) != -1):
|
||||
false;
|
||||
case Failure(_):
|
||||
@@ -332,6 +342,7 @@ class SpecialForms {
|
||||
default: true;
|
||||
}
|
||||
} else true;
|
||||
}
|
||||
|
||||
var cases = args.slice(1);
|
||||
// case also override's haxe's switch() behavior by refusing to match null values against <var> patterns.
|
||||
|
||||
Reference in New Issue
Block a user