Skip to content

Commit

Permalink
fix(Ast): Fix angulardart#1502, bad recovery.
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey committed Aug 17, 2018
1 parent 5c9d83e commit 40e467d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion angular_ast/lib/src/visitors/desugar_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ class DesugarVisitor implements TemplateAstVisitor<TemplateAst, String> {
);
} catch (e) {
exceptionHandler.handle(e);
return astNode;
if (astNode is EmbeddedTemplateAst) {
return astNode;
}
// We parsed this as something unexpected, and should not continue.
rethrow;
}
if (micro != null) {
propertiesToAdd.addAll(micro.properties);
Expand Down
8 changes: 8 additions & 0 deletions angular_ast/test/expression/micro/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:angular_ast/angular_ast.dart';
import 'package:angular_ast/src/ast.dart';
import 'package:angular_ast/src/expression/micro/ast.dart';
import 'package:angular_ast/src/expression/micro/parser.dart';
Expand Down Expand Up @@ -124,4 +125,11 @@ void main() {
),
);
});

test('should a parser error on trailing semi-colon', () {
expect(
() => parse('ngFor', 'let item of items;', 0),
throwsA(TypeMatcher<AngularParserException>()),
);
});
}

0 comments on commit 40e467d

Please sign in to comment.