Getter Expressions

A getter expressions consists of the @ character followed by an object property name or an array index. It retrieves the value of the property or the element at the index for an input object or array. The input type must guarantee the existence of the property/index, otherwise a type error is raised. If the input type cannot guarantee the existence of the property/index, use the get funcer for objects or for arrays.

ProgramTypeValueError
{a: 1, b: 2} @aNum1
{a: 1, b: 2} @bNum2
{a: 1, b: 2} @cType error
Code: NoSuchProperty
Message: The object does not have this property.
Want type: Obj<c: Any, Any>
Got type: Obj<a: Num, b: Num, Void>
{0: "a"} @0Str"a"
["a", "b", "c"] @0Str"a"
["a", "b", "c"] @1Str"b"
["a", "b", "c"] @2Str"c"
["a", "b", "c"] @3Type error
Code: NoSuchIndex
Message: Array is not long enough.
["a", "b", "c"] @-1Type error
Code: BadIndex
Message: Index must be a nonnegative integer.
["a", "b", "c"] @1.5Type error
Code: BadIndex
Message: Index must be a nonnegative integer.
"abc" @1Type error
Code: NoGetterAllowed
Message: A getter expression cannot be applied to this type.
24 @1Type error
Code: NoGetterAllowed
Message: A getter expression cannot be applied to this type.
for Any def f Arr<Any...> as [] ok f @1Type error
Code: NoGetterAllowed
Message: A getter expression cannot be applied to this type.