Artifact c9a55d8e7b3293ae87367d7e4e6c3f032534e99c
@@type = fun(x){
if( _isint(x) ) { "int" }
else { if( _isstr(x) ) { "str" }
else { if( _isfun(x) ) { x }
else { if( _isundefined(x) ) { "undefined" }
else { "any" }}}}
};
def binop(a,b,c) {
fun(x,y){@v(
if( @type(x)=="undefined" || @type(y)=="undefined" ) { "undefined" } else {
if( @type(x)==a && @type(y)==b ) { 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) {@v(
if(@type(c)=="int" ) { mergeType(@type(t()), @type(e())) } else { "error" }
)};