daScript
daScript copied to clipboard
if_ref not working for value types
looks like if_ref/is_ref_value not working for value types
options log_infer_passes=true
[export]
def main
var a: int
var b: int& = a
print("{typeinfo(typename type<int&>)}\n")
print("{typeinfo(is_ref type<int&>)}\n")
print("{typeinfo(is_ref_value type<int&>)}\n")
print("{typeinfo(is_ref_type type<int&>)}\n")
print("\n")
print("{typeinfo(typename b)}\n")
print("{typeinfo(is_ref b)}\n")
print("{typeinfo(is_ref_value b)}\n")
print("{typeinfo(is_ref_type b)}\n")
//Output:
int&
true
true
false
int
false
false
false
its an interesting case. i need to think about it - because both behaviors for local refs are viable
the more i think about it, the more i think its correct behavior. we can add is_ref_variable if we ever encounter a case, where this distinction is necessary. so far just 'b' is correct to not b e a ref.
print("{typeinfo(typename a)}\n")
print("{typeinfo(is_ref a)}\n")
print("{typeinfo(is_ref_value a)}\n")
print("{typeinfo(is_ref_type a)}\n")
also prints int,false,false,false.