Pattern assignment statements (extracted from: Primitive type patterns and conversions)

Tagir Valeev amaembo at
Tue Mar 2 10:47:20 UTC 2021

On Tue, Mar 2, 2021 at 5:05 AM Brian Goetz <brian.goetz at> wrote:
> as *either* a local variable declaration, *or* a pattern match, without the user being able to tell the difference:
>  - The scoping is the same (since the pattern either completes normally or throws);
>  - The mutability is the same (we fixed this one just in time);
>  - The set of conversions, applicable types, and potential exceptions are the same (exercise left to the reader.)

A couple of other things to consider:
1. C-style array declaration is not allowed in patterns.
2. For local variable declaration, the initializer can omit `new int[]` part:
int data[] = {1, 2, 3}
3. Local variable type may affect the initializer type (e.g.
List<String> list = List.of()). What about patterns? Can we say that a
`List<String> list` pattern is a total pattern over `List.of()`
expression type?

With best regards,
Tagir Valeev

More information about the amber-spec-experts mailing list