Change handling of invalid patterns to produce a valid parse tree. (#2768)

At present, `var *;` is a crash because it has errors that weren't being properly stored/handled. This changes the handling to give more to track invalid parses in patterns.
This commit is contained in:
Jon Ross-Perkins
2023-04-15 03:22:31 -07:00
committed by GitHub
parent 1f49c3e36d
commit 3cab211489
15 changed files with 87 additions and 39 deletions
@@ -8,8 +8,11 @@
// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Div'},
// CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['},
// CHECK:STDOUT: {kind: 'DeducedParameterList', text: ']', has_error: yes, subtree_size: 2},
// CHECK:STDOUT: {kind: 'FunctionDeclaration', text: 'fn', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'DeclaredName', text: '(', has_error: yes},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '(', has_error: yes},
// CHECK:STDOUT: {kind: 'PatternBinding', text: '(', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'DeducedParameterList', text: ']', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'FunctionDeclaration', text: 'fn', has_error: yes, subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
@@ -8,9 +8,11 @@
// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'foo'},
// CHECK:STDOUT: {kind: 'ParameterListStart', text: '('},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'bar'},
// CHECK:STDOUT: {kind: 'ParameterList', text: ')', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', subtree_size: 6},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'bar'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes},
// CHECK:STDOUT: {kind: 'PatternBinding', text: 'bar', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'ParameterList', text: ')', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]