supertypeof
the type of a value including its fusion types
Synopsis
supertypeof(val: any) -> type
Description
The supertypeof function returns the type of
its argument val like typeof except that val is not
superdefused before its type is computed. For a value
whose type includes fusion types, e.g., a value
produced by superfuse, the returned type
includes the fusion types whereas typeof returns the type of the original
value. For any other value, supertypeof is the same as typeof.
supertypeof is useful for testing and debugging since fusion types are
otherwise visible only in output with the -fusion flag.
Examples
The type of a superfused value includes its fusion types
# spq
superfuse | values {super:supertypeof(this),type:typeof(this)}
# input
{a:1}
{a:"x",b:2}
# expected output
{super:<{a:fusion(int64|string),b:fusion(int64|missing)}>,type:<{a:int64}>}
{super:<{a:fusion(int64|string),b:fusion(int64|missing)}>,type:<{a:string,b:int64}>}