-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
The start locations of TypeofExpression and VoidExpression are incorrect.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
import {
Lexer,
ParseLocation,
Parser,
ParseSourceFile,
ParseSourceSpan,
} from '@angular/compiler';
function getFakeSpan(fileName = 'test.html') {
const file = new ParseSourceFile('', fileName);
const location = new ParseLocation(file, 0, 0, 0);
return new ParseSourceSpan(location, location);
}
const parse = (text) => {
const lexer = new Lexer();
const parser = new Parser(lexer);
return parser.parseBinding(text, getFakeSpan(), 0);
};
console.log(parse('typeof a').ast);
console.log(parse('void a').ast);TypeofExpression {
span: ParseSpan { start: 7, end: 8 },
sourceSpan: AbsoluteSourceSpan { start: 7, end: 8 }, // <-- Should start at 0, not 7
expression: PropertyRead {
span: ParseSpan { start: 7, end: 8 },
sourceSpan: AbsoluteSourceSpan { start: 7, end: 8 },
nameSpan: AbsoluteSourceSpan { start: 7, end: 8 },
receiver: ImplicitReceiver {
span: [ParseSpan],
sourceSpan: [AbsoluteSourceSpan]
},
name: 'a'
}
}
VoidExpression {
span: ParseSpan { start: 5, end: 6 },
sourceSpan: AbsoluteSourceSpan { start: 5, end: 6 }, // <-- Should start at 0, not 5
expression: PropertyRead {
span: ParseSpan { start: 5, end: 6 },
sourceSpan: AbsoluteSourceSpan { start: 5, end: 6 },
nameSpan: AbsoluteSourceSpan { start: 5, end: 6 },
receiver: ImplicitReceiver {
span: [ParseSpan],
sourceSpan: [AbsoluteSourceSpan]
},
name: 'a'
}
}
Please provide the environment you discovered this bug in (run ng version)
@angular/compiler 21.0.5
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerstate: has PR