ballerina-platform / ballerina-spec

Ballerina Language and Platform Specifications
Other
167 stars 54 forks source link

Specify semantics of error-arg-list-match-pattern #617

Open KavinduZoysa opened 4 years ago

KavinduZoysa commented 4 years ago

Description:

error-match-pattern := error [error-type-reference] ( error-arg-list-match-pattern )
error-arg-list-match-pattern :=
   error-message-match-pattern [, error-cause-match-pattern] [, error-field-match-patterns]
   | [error-field-match-patterns]

According to the spec, error-arg-list-match-pattern can contain error-field-match-patterns, without error-message-match-pattern and error-cause-match-pattern.

ex:

match v {
    error ( c = 200 ) => {}
}

But according to the error-constructor-expr, first positional-arg should be a string. Therefore can we find any error value which matches above example?

jclark commented 4 years ago

The semantics of an error-arg-list-match-pattern is that each thing specified in the pattern must be present with the specified value in the error. Things that are not specified in the error-arg-list-match-pattern do not affect the match. So if there is no message or cause specified, then the meaning is that the message or cause do not affect whether the pattern matches. The semantics is not that the message must be absent (which is never possible). This is the same semantics as for mapping match patterns.