Artifact f80a12af3228ea33de3581cfd28314567c98d1a1
@@type = fun(x){
if _isint(x): "int"
else if _isstr(x): "str"
else if _isundefined(x): "undefined"
else: "any"
};
def binop(a,b,c) {
fun(x,y){@value(
if( @type(x)=="undefined" || @type(y)=="undefined" ) then "undefined" else
if( @type(x)==a && @type(y)==b ) then c else "error"
)}
};
@type "+" = binop("int", "int", "int");
@type "-" = binop("int", "int", "int");
@type "<" = binop("int", "int", "int");
@type ">" = binop("int", "int", "int");
def mergeType(a,b) {
if( a == "undefined" ): ( if(b=="undefined"):"error" else b ) else ( a )
};
@type "if" = fun(c,t,e) {@value(
if(@type(c)=="int" ): mergeType(@type(t()), @type(e())) else : "error"
)};