any will be depreciated after the implementation of binding type
variables
This commit is contained in:
Umur Ozkul 2022-07-28 22:25:51 +02:00
parent 6733319403
commit e1c53c9087
2 changed files with 11 additions and 4 deletions

View File

@ -68,3 +68,5 @@ myTypeCheckTest(test, "number | string", "1", "Ok")
myTypeCheckTest(test, "date | string", "1", "Expected type: (date | string) but got: 1")
myTypeCheckTest(test, "number<-min(10)", "10", "Ok")
myTypeCheckTest(test, "number<-min(10)", "0", "Expected type: number<-min(10) but got: 0")
myTypeCheckTest(test, "any", "0", "Ok")
myTypeCheckTest(test, "any", "'a'", "Ok")

View File

@ -7,10 +7,15 @@ open InternalExpressionValue
let rec isITypeOf = (anIType: T.iType, aValue): result<bool, T.typeErrorValue> => {
let caseTypeIdentifier = (anUpperTypeName, aValue) => {
let aTypeName = anUpperTypeName->Js.String2.toLowerCase
let valueTypeName = aValue->valueToValueType->valueTypeToString->Js.String2.toLowerCase
switch aTypeName == valueTypeName {
| true => Ok(true)
| false => T.TypeMismatch(anIType, aValue)->Error
switch aTypeName {
| "any" => Ok(true)
| _ => {
let valueTypeName = aValue->valueToValueType->valueTypeToString->Js.String2.toLowerCase
switch aTypeName == valueTypeName {
| true => Ok(true)
| false => T.TypeMismatch(anIType, aValue)->Error
}
}
}
}