Skip to content
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

Emit an error instead of aborting when inferring unused type parameters #766

Merged
merged 1 commit into from Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/compiler.ts
Expand Up @@ -5868,8 +5868,21 @@ export class Compiler extends DiagnosticEmitter {
}
let resolvedTypeArguments = new Array<Type>(numTypeParameters);
for (let i = 0; i < numTypeParameters; ++i) {
let inferredType = assert(inferredTypes.get(typeParameterNodes[i].name.text)); // TODO
resolvedTypeArguments[i] = inferredType;
let name = typeParameterNodes[i].name.text;
if (inferredTypes.has(name)) {
let inferredType = inferredTypes.get(name);
if (inferredType) {
resolvedTypeArguments[i] = inferredType;
continue;
}
}
// unused template, e.g. `function test<T>(): void {...}` called as `test()`
// invalid because the type is effectively unknown inside the function body
this.error(
DiagnosticCode.Type_argument_expected,
expression.expression.range.atEnd
);
return this.module.unreachable();
}
instance = this.resolver.resolveFunction(
prototype,
Expand Down