Skip to content

Rework loop statement compilation / general cleanup #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
761 changes: 491 additions & 270 deletions src/compiler.ts

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ export abstract class DiagnosticEmitter {

/** Diagnostic messages emitted so far. */
diagnostics: DiagnosticMessage[];
/** Diagnostic messages already seen, by range. */
private seen: Map<Range,Set<DiagnosticCode>> = new Map();

/** Initializes this diagnostic emitter. */
protected constructor(diagnostics: DiagnosticMessage[] | null = null) {
Expand All @@ -277,6 +279,19 @@ export abstract class DiagnosticEmitter {
arg1: string | null = null,
arg2: string | null = null
): void {
// It is possible that the same diagnostic is emitted twice, for example
// when compiling generics with different types or when recompiling a loop
// because our initial assumptions didn't hold. Deduplicate these.
var seen = this.seen;
if (seen.has(range)) {
let codes = seen.get(range)!;
if (codes.has(code)) return;
codes.add(code);
} else {
let codes = new Set<DiagnosticCode>();
codes.add(code);
seen.set(range, codes);
}
var message = DiagnosticMessage.create(code, category, arg0, arg1, arg2).withRange(range);
if (relatedRange) message.relatedRange = relatedRange;
this.diagnostics.push(message);
Expand Down
Loading