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 access = fieldAccess(formName, name, args[0]);
|
||||||
|
|
||||||
var type = Helpers.explicitType(args[0]);
|
var type = Helpers.explicitType(args[0]);
|
||||||
|
if (type != null)
|
||||||
k.typeHints.push({name: name, type: type});
|
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):
|
case ListExp(funcArgs):
|
||||||
funcArgs.map(makeFuncArg);
|
funcArgs.map(makeFuncArg);
|
||||||
case CallExp(_, _):
|
case CallExp(_, _):
|
||||||
@@ -190,6 +190,7 @@ class Helpers {
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
for (v in vars) {
|
for (v in vars) {
|
||||||
|
if (v.type != null)
|
||||||
k.typeHints.push(v);
|
k.typeHints.push(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +207,7 @@ class Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (v in vars) {
|
for (v in vars) {
|
||||||
|
if (v.type != null)
|
||||||
k.typeHints.remove(v);
|
k.typeHints.remove(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +219,7 @@ class Helpers {
|
|||||||
ret: if (name != null) Helpers.explicitType(name) else null,
|
ret: if (name != null) Helpers.explicitType(name) else null,
|
||||||
args: args,
|
args: args,
|
||||||
expr: expr
|
expr: expr
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// The name of this function is confusing--it actually makes a Haxe `case` expression, not a switch-case expression
|
// 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) {
|
for (v in varDefs) {
|
||||||
|
if (v.type != null)
|
||||||
k.typeHints.push(v);
|
k.typeHints.push(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +214,7 @@ class SpecialForms {
|
|||||||
]).withMacroPosOf(wholeExp);
|
]).withMacroPosOf(wholeExp);
|
||||||
|
|
||||||
for (v in varDefs) {
|
for (v in varDefs) {
|
||||||
|
if (v.type != null)
|
||||||
k.typeHints.remove(v);
|
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.
|
// 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.
|
// 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')) {
|
var canCompareNull = switch (args[0].def) {
|
||||||
switch (exp.typeof(k.typeHints)) {
|
// 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):
|
case Success(TAbstract(ref, [])) if (["Int", "Float", "Bool"].indexOf(ref.get().name) != -1):
|
||||||
false;
|
false;
|
||||||
case Failure(_):
|
case Failure(_):
|
||||||
@@ -332,6 +342,7 @@ class SpecialForms {
|
|||||||
default: true;
|
default: true;
|
||||||
}
|
}
|
||||||
} else true;
|
} else true;
|
||||||
|
}
|
||||||
|
|
||||||
var cases = args.slice(1);
|
var cases = args.slice(1);
|
||||||
// case also override's haxe's switch() behavior by refusing to match null values against <var> patterns.
|
// case also override's haxe's switch() behavior by refusing to match null values against <var> patterns.
|
||||||
|
|||||||
Reference in New Issue
Block a user