any type
any will be depreciated after the implementation of binding type variables
This commit is contained in:
parent
6733319403
commit
e1c53c9087
|
@ -68,3 +68,5 @@ myTypeCheckTest(test, "number | string", "1", "Ok")
|
||||||
myTypeCheckTest(test, "date | string", "1", "Expected type: (date | string) but got: 1")
|
myTypeCheckTest(test, "date | string", "1", "Expected type: (date | string) but got: 1")
|
||||||
myTypeCheckTest(test, "number<-min(10)", "10", "Ok")
|
myTypeCheckTest(test, "number<-min(10)", "10", "Ok")
|
||||||
myTypeCheckTest(test, "number<-min(10)", "0", "Expected type: number<-min(10) but got: 0")
|
myTypeCheckTest(test, "number<-min(10)", "0", "Expected type: number<-min(10) but got: 0")
|
||||||
|
myTypeCheckTest(test, "any", "0", "Ok")
|
||||||
|
myTypeCheckTest(test, "any", "'a'", "Ok")
|
||||||
|
|
|
@ -7,10 +7,15 @@ open InternalExpressionValue
|
||||||
let rec isITypeOf = (anIType: T.iType, aValue): result<bool, T.typeErrorValue> => {
|
let rec isITypeOf = (anIType: T.iType, aValue): result<bool, T.typeErrorValue> => {
|
||||||
let caseTypeIdentifier = (anUpperTypeName, aValue) => {
|
let caseTypeIdentifier = (anUpperTypeName, aValue) => {
|
||||||
let aTypeName = anUpperTypeName->Js.String2.toLowerCase
|
let aTypeName = anUpperTypeName->Js.String2.toLowerCase
|
||||||
let valueTypeName = aValue->valueToValueType->valueTypeToString->Js.String2.toLowerCase
|
switch aTypeName {
|
||||||
switch aTypeName == valueTypeName {
|
| "any" => Ok(true)
|
||||||
| true => Ok(true)
|
| _ => {
|
||||||
| false => T.TypeMismatch(anIType, aValue)->Error
|
let valueTypeName = aValue->valueToValueType->valueTypeToString->Js.String2.toLowerCase
|
||||||
|
switch aTypeName == valueTypeName {
|
||||||
|
| true => Ok(true)
|
||||||
|
| false => T.TypeMismatch(anIType, aValue)->Error
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user