Johnni Winther
31e119e594
[cfe] Report error on empty map pattern
...
This reports the error on empty map pattern and moves the reporting
of rest patterns in map patterns to the shared analysis.
Change-Id: I317d0c42a3bc7534462b1b9781c1f6471746fc0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292860
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-04-04 09:36:38 +00:00
Johnni Winther
23f09803e2
[cfe] Mark pattern variables as having a declared initializer
...
Closes #51710
Change-Id: I204ec4b671835b8d51056871ab89365d9afb78b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292702
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-04-03 10:08:46 +00:00
Johnni Winther
1536bbab40
[cfe] Updates test with ... in map patterns
...
Change-Id: I6dceb6d9490c3b42941874499e815638216b0d17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292302
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-31 09:54:56 +00:00
Johnni Winther
7914382b50
[cfe] Remove length check from map pattern matching
...
In response to https://github.com/dart-lang/language/pull/2960
TEST=existing expectation tests
Change-Id: I5c0d9070b98074c167dea0a0b9a0d576d4aa33d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291825
Reviewed-by: Slava Egorov <vegorov@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-30 11:26:08 +00:00
Johnni Winther
2528bf8666
[kernel] Add VariableDeclaration.isHoisted
...
This flag is set when a variable declaration is moved earlier in
order to be available for subsequent code that couldn't contain
its declaration. For instance variables declared in patterns which
needs to be declared before the matching expressions that initialize
them.
TEST=existing expectations tests
Change-Id: I80ab1138f08f725f3e01905c1a57a1483f809328
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291820
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-30 07:13:40 +00:00
Johnni Winther
d16118c4d1
[cfe] Delay assignment in pattern assignment until after matching
...
Closes #51861
Change-Id: I5681bdf8198c676599daca79910b066fa18c283b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291541
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-29 12:17:32 +00:00
Chloe Stefantsova
628ba2ac64
[cfe] Use StateError as the pattern matching error in assignments
...
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I9c4fb121526ca40e5809be8f4a8a5770d551cfb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291063
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
2023-03-24 11:30:57 +00:00
Johnni Winther
a6d23ad697
[cfe] Skip lookups for wildcards in list patterns
...
Closes #51771
Change-Id: I1b79beb1df3c5d9c35e109505a04f51926db679d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289603
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-03-23 17:53:30 +00:00
Chloe Stefantsova
cfe9932a9e
[cfe] Make pattern matching error a StateError
...
This is the first step in adjusting the runtime error raised on a
pattern mismatch in an irrefutable context. For now, the error message
isn't specialized and doesn't reflect the nature of the mismatch.
Part of https://github.com/dart-lang/sdk/issues/51720
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: Ie4b997a1a36e92b25f1372f4dd98941dbcc08b61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290842
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-03-23 16:10:16 +00:00
Johnni Winther
6480e28d5a
[cfe] Don't check length on List/Map only containing a rest pattern
...
Includes a fix for matched value type being invalid, encountered
during development.
Closes #51770
Change-Id: I0c960eaef528f16789e8d9a42340e50f05326cf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289602
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-21 08:39:38 +00:00
Johnni Winther
6d2e6f9452
[cfe] Improve switch encoding
...
Addresses https://github.com/dart-lang/sdk/issues/51554#issuecomment-1466946211
Closes #51391
TEST=existing
Change-Id: Idec105dcfde4a91d0a21a1907777d6c07e5f01b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289224
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
2023-03-20 15:21:52 +00:00
Johnni Winther
04e6f4c282
[kernel] Add VariableDeclaration.isSynthesized
...
This adds an [isSynthesized] flag to the [VariableDeclaration] the
signal when the variable doesn't correspond to a variable in the
source code.
The name of a variable can only be `null` if it is synthesized.
Partially in response to
https://github.com/dart-lang/sdk/issues/51554
TEST=existing
Change-Id: I94591971f11da09d210c8b25a2d05e22ca05dc62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286961
Reviewed-by: Joshua Litt <joshualitt@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
2023-03-10 11:13:36 +00:00
Johnni Winther
c9e29fa85f
[_fe_analyzer_shared] Include errors in analysis result
...
This propagates information about reported error to the caller of
a shared type analysis. This is used to properly turn errors into
invalid expressions/patterns, as is normally done in the CFE in
face of errors.
Change-Id: Ibb8adedccb8314fabfe18ecaa3559e32ad7267ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286145
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2023-03-06 22:06:00 +00:00
Johnni Winther
2836f56729
[cfe] Decouple MatchingCache and MatchingExpressionVisitor from inference
...
This moves the computation values need for the lowering to the
inference visitor and passes these to the lowering through fields on
the patterns.
This prepares for performing lowering during constant evaluation.
Change-Id: I71a63ac3fd911d9b0cfa5de00a6d28e3b9571a00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282600
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-02-13 10:37:00 +00:00
Johnni Winther
f3f5f724c5
[cfe] Add matched type to patterns
...
This stores the matched type, as computed by the flow analysis, into
patterns that use it in their lowering.
This ensures that flow is taken into account in the matching expressions
and also prepares for decoupling the matching expression generation
from the inference visitor.
Change-Id: Ifabd3b027d91a70fcbc6bb4180fbb11406e70df1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282401
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-02-13 10:37:00 +00:00
Johnni Winther
5d44b804cd
[cfe] Avoid unnecessary switch statements
...
This changes the lowering of switch expressions and pattern switch
statements without continue to only use if-then-else
Change-Id: I3bcbb634ec3153a117c4bd6692a276c1c26e648d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279964
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-01-31 18:12:44 +00:00
Chloe Stefantsova
b0cc8afcc9
[cfe] Adjust scoping for single-head cases in pattern switches
...
Closes https://github.com/dart-lang/sdk/issues/50898
Closes https://github.com/dart-lang/sdk/issues/51112
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I41d891021e266835bb71094b6096a36a14dd0275
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280103
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-01-31 13:48:40 +00:00
Paul Berry
9c08c99565
front_end: fix expectations for shared_errors test.
...
This test is failing on CFE bots, probably due to a conflict between
https://dart-review.googlesource.com/c/sdk/+/280086 and some other CL.
Updating the test expectations to turn the bots green again.
Change-Id: I8f2a38877bc4be3ee931674fd9ffecf3fc5a0e10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280127
Auto-Submit: Paul Berry <paulberry@google.com >
Commit-Queue: Nate Bosch <nbosch@google.com >
Reviewed-by: Nate Bosch <nbosch@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2023-01-31 00:34:49 +00:00
Johnni Winther
ed7124884a
[cfe] Implement shared error reporting
...
Change-Id: Ief8d557d0e6553fa79e7281172caccb00dfc5cfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280086
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Paul Berry <paulberry@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-01-30 18:42:38 +00:00