wdl icon indicating copy to clipboard operation
wdl copied to clipboard

Clarify access to a non-existent `Object` member

Open jdidion opened this issue 1 year ago • 3 comments

Currently the spec does not state whether accessing an object member that does not exist results in a None or an error. E.g.

Object foo = object { a: 1 }
Int b = foo.b  # what happens here??

I suggest that the result should be a None, since there is currently no way to check the existence of an Object member.

jdidion avatar Dec 11 '23 18:12 jdidion

I suggest an error.

input:
  my_optional_string=foo.b

Should throw an error when b does not exist, rather than silently putting in a None.

rhpvorderman avatar Dec 12 '23 07:12 rhpvorderman

That's a good point - I would expect an error in that case.

Maybe we can have contains_key() (#305 ) accept either a Map or Object?

jdidion avatar Dec 12 '23 22:12 jdidion

I am in favour of an error as well with a preference for using the contains_key function. Most languages raise some sort of access error when you are trying to do a direct access and the key does not exist

patmagee avatar Dec 20 '23 15:12 patmagee