refactor(compiler): add details while throw error during expression convert (#32760)
Fixes #32759 PR Close #32760
This commit is contained in:
parent
15fefdbb8d
commit
f4caf263d4
|
@ -551,7 +551,10 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
|
|||
this.usesImplicitReceiver = prevUsesImplicitReceiver;
|
||||
} else {
|
||||
// Otherwise it's an error.
|
||||
throw new Error('Cannot assign to a reference or variable!');
|
||||
const receiver = ast.name;
|
||||
const value = (ast.value instanceof cdAst.PropertyRead) ? ast.value.name : undefined;
|
||||
throw new Error(
|
||||
`Cannot assign value "${value}" to template variable "${receiver}". Template variables are read-only.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -662,9 +662,9 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
|
|||
}));
|
||||
|
||||
it('should throw when trying to assign to a local', fakeAsync(() => {
|
||||
expect(() => {
|
||||
_bindSimpleProp('(event)="$event=1"');
|
||||
}).toThrowError(new RegExp('Cannot assign to a reference or variable!'));
|
||||
expect(() => { _bindSimpleProp('(event)="$event=1"'); })
|
||||
.toThrowError(new RegExp(
|
||||
'Cannot assign value (.*) to template variable (.*). Template variables are read-only.'));
|
||||
}));
|
||||
|
||||
it('should support short-circuiting', fakeAsync(() => {
|
||||
|
|
Loading…
Reference in New Issue