fix(ivy): don't crash on unknown pipe (#33454)
Previously the compiler would crash if a pipe was encountered which did not match any pipe in the scope of a template. This commit introduces a new diagnostic error for unknown pipes instead. PR Close #33454
This commit is contained in:
@ -145,7 +145,7 @@ export class KeyedWrite extends AST {
|
||||
export class BindingPipe extends AST {
|
||||
constructor(
|
||||
span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public exp: AST, public name: string,
|
||||
public args: any[]) {
|
||||
public args: any[], public nameSpan: ParseSpan) {
|
||||
super(span, sourceSpan);
|
||||
}
|
||||
visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPipe(this, context); }
|
||||
@ -484,7 +484,8 @@ export class AstTransformer implements AstVisitor {
|
||||
|
||||
visitPipe(ast: BindingPipe, context: any): AST {
|
||||
return new BindingPipe(
|
||||
ast.span, ast.sourceSpan, ast.exp.visit(this), ast.name, this.visitAll(ast.args));
|
||||
ast.span, ast.sourceSpan, ast.exp.visit(this), ast.name, this.visitAll(ast.args),
|
||||
ast.nameSpan);
|
||||
}
|
||||
|
||||
visitKeyedRead(ast: KeyedRead, context: any): AST {
|
||||
@ -635,7 +636,7 @@ export class AstMemoryEfficientTransformer implements AstVisitor {
|
||||
const exp = ast.exp.visit(this);
|
||||
const args = this.visitAll(ast.args);
|
||||
if (exp !== ast.exp || args !== ast.args) {
|
||||
return new BindingPipe(ast.span, ast.sourceSpan, exp, ast.name, args);
|
||||
return new BindingPipe(ast.span, ast.sourceSpan, exp, ast.name, args, ast.nameSpan);
|
||||
}
|
||||
return ast;
|
||||
}
|
||||
|
@ -348,13 +348,16 @@ export class _ParseAST {
|
||||
}
|
||||
|
||||
do {
|
||||
const nameStart = this.inputIndex;
|
||||
const name = this.expectIdentifierOrKeyword();
|
||||
const nameSpan = this.span(nameStart);
|
||||
const args: AST[] = [];
|
||||
while (this.optionalCharacter(chars.$COLON)) {
|
||||
args.push(this.parseExpression());
|
||||
}
|
||||
const {start} = result.span;
|
||||
result = new BindingPipe(this.span(start), this.sourceSpan(start), result, name, args);
|
||||
result =
|
||||
new BindingPipe(this.span(start), this.sourceSpan(start), result, name, args, nameSpan);
|
||||
} while (this.optionalOperator('|'));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user