Skip to content

Reference feature in not implemented diagnostic #1295

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 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2838,8 +2838,9 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
}
}
compiler.error(
DiagnosticCode.Not_implemented,
ctx.reportNode.typeArgumentsRange
DiagnosticCode.Operation_0_cannot_be_applied_to_type_1,
ctx.reportNode.typeArgumentsRange,
"assert", compiler.currentType.toString()
);
return abort;
}
Expand Down
106 changes: 52 additions & 54 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1531,10 +1531,12 @@ export class Compiler extends DiagnosticEmitter {

// Just prepended allocation is dropped when returning non-'this'
if (flow.is(FlowFlags.MAY_RETURN_NONTHIS)) {
this.pedantic(
DiagnosticCode.Explicitly_returning_constructor_drops_this_allocation,
instance.identifierNode.range
);
if (this.options.pedantic) {
this.pedantic(
DiagnosticCode.Explicitly_returning_constructor_drops_this_allocation,
instance.identifierNode.range
);
}
}
}

Expand Down Expand Up @@ -2107,8 +2109,9 @@ export class Compiler extends DiagnosticEmitter {
case NodeKind.TYPEDECLARATION: {
// TODO: integrate inner type declaration into flow
this.error(
DiagnosticCode.Not_implemented,
statement.range
DiagnosticCode.Not_implemented_0,
statement.range,
"Inner type alias"
);
stmt = module.unreachable();
break;
Expand Down Expand Up @@ -2182,8 +2185,9 @@ export class Compiler extends DiagnosticEmitter {
var labelNode = statement.label;
if (labelNode) {
this.error(
DiagnosticCode.Not_implemented,
labelNode.range
DiagnosticCode.Not_implemented_0,
labelNode.range,
"Break label"
);
return module.unreachable();
}
Expand Down Expand Up @@ -2216,8 +2220,9 @@ export class Compiler extends DiagnosticEmitter {
var label = statement.label;
if (label) {
this.error(
DiagnosticCode.Not_implemented,
label.range
DiagnosticCode.Not_implemented_0,
label.range,
"Continue label"
);
return module.unreachable();
}
Expand Down Expand Up @@ -2581,8 +2586,9 @@ export class Compiler extends DiagnosticEmitter {
statement: ForOfStatement
): ExpressionRef {
this.error(
DiagnosticCode.Not_implemented,
statement.range
DiagnosticCode.Not_implemented_0,
statement.range,
"Iterators"
);
return this.module.unreachable();
}
Expand Down Expand Up @@ -2915,8 +2921,9 @@ export class Compiler extends DiagnosticEmitter {
// TODO: can't yet support something like: try { return ... } finally { ... }
// worthwhile to investigate lowering returns to block results (here)?
this.error(
DiagnosticCode.Not_implemented,
statement.range
DiagnosticCode.Not_implemented_0,
statement.range,
"Exceptions"
);
return this.module.unreachable();
}
Expand Down Expand Up @@ -3453,10 +3460,7 @@ export class Compiler extends DiagnosticEmitter {
break;
}
default: {
this.error(
DiagnosticCode.Not_implemented,
expression.range
);
assert(false);
expr = this.module.unreachable();
}
}
Expand Down Expand Up @@ -3782,8 +3786,9 @@ export class Compiler extends DiagnosticEmitter {
// }
// }
this.error(
DiagnosticCode.Not_implemented,
expression.range
DiagnosticCode.Not_implemented_0,
expression.range,
"Const assertion"
);
return this.module.unreachable();
}
Expand Down Expand Up @@ -4312,8 +4317,9 @@ export class Compiler extends DiagnosticEmitter {
case TypeKind.ANYREF: {
// TODO: ref.eq
this.error(
DiagnosticCode.Not_implemented,
expression.range
DiagnosticCode.Not_implemented_0,
expression.range,
"ref.eq instruction"
);
expr = module.unreachable();
break;
Expand Down Expand Up @@ -4412,8 +4418,9 @@ export class Compiler extends DiagnosticEmitter {
case TypeKind.ANYREF: {
// TODO: !ref.eq
this.error(
DiagnosticCode.Not_implemented,
expression.range
DiagnosticCode.Not_implemented_0,
expression.range,
"ref.eq instruction"
);
expr = module.unreachable();
break;
Expand Down Expand Up @@ -5950,10 +5957,7 @@ export class Compiler extends DiagnosticEmitter {
break;
}
default: {
this.error(
DiagnosticCode.Not_implemented,
expression.range
);
assert(false);
return this.module.unreachable();
}
}
Expand Down Expand Up @@ -6154,10 +6158,7 @@ export class Compiler extends DiagnosticEmitter {
}
}
}
this.error(
DiagnosticCode.Not_implemented,
valueExpression.range
);
assert(false);
return module.unreachable();
}

Expand Down Expand Up @@ -6627,10 +6628,7 @@ export class Compiler extends DiagnosticEmitter {
false
));
}
this.error(
DiagnosticCode.Not_implemented,
expression.expression.range
);
assert(false);
return this.module.unreachable();
}

Expand Down Expand Up @@ -6659,8 +6657,9 @@ export class Compiler extends DiagnosticEmitter {
var hasRest = signature.hasRest;
if (hasRest) {
this.error(
DiagnosticCode.Not_implemented,
reportNode.range
DiagnosticCode.Not_implemented_0,
reportNode.range,
"Rest parameters"
);
return false;
}
Expand Down Expand Up @@ -8148,8 +8147,9 @@ export class Compiler extends DiagnosticEmitter {
if (target.parent != flow.parentFunction) {
// TODO: closures
this.error(
DiagnosticCode.Not_implemented,
expression.range
DiagnosticCode.Not_implemented_0,
expression.range,
"Closures"
);
return module.unreachable();
}
Expand Down Expand Up @@ -8212,10 +8212,7 @@ export class Compiler extends DiagnosticEmitter {
return module.i32(index);
}
}
this.error(
DiagnosticCode.Not_implemented,
expression.range
);
assert(false);
return this.module.unreachable();
}

Expand Down Expand Up @@ -8465,13 +8462,17 @@ export class Compiler extends DiagnosticEmitter {
assert(!implicitlyNegate);
return this.compileObjectLiteral(<ObjectLiteralExpression>expression, contextualType);
}
// case LiteralKind.REGEXP:
case LiteralKind.REGEXP: {
this.error(
DiagnosticCode.Not_implemented_0,
expression.range,
"Regular expressions"
);
this.currentType = contextualType;
return module.unreachable();
}
}
this.error(
DiagnosticCode.Not_implemented,
expression.range
);
this.currentType = contextualType;
assert(false);
return module.unreachable();
}

Expand Down Expand Up @@ -9318,10 +9319,7 @@ export class Compiler extends DiagnosticEmitter {
return module.unreachable();
}
}
this.error(
DiagnosticCode.Not_implemented,
expression.range
);
assert(false);
return module.unreachable();
}

Expand Down
4 changes: 2 additions & 2 deletions src/diagnosticMessages.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/** Enum of available diagnostic codes. */
export enum DiagnosticCode {
Not_implemented = 100,
Not_implemented_0 = 100,
Operation_is_unsafe = 101,
User_defined_0 = 102,
Feature_0_is_not_enabled = 103,
Expand Down Expand Up @@ -180,7 +180,7 @@ export enum DiagnosticCode {
/** Translates a diagnostic code to its respective string. */
export function diagnosticCodeToString(code: DiagnosticCode): string {
switch (code) {
case 100: return "Not implemented.";
case 100: return "Not implemented: {0}";
case 101: return "Operation is unsafe.";
case 102: return "User-defined: {0}";
case 103: return "Feature '{0}' is not enabled.";
Expand Down
2 changes: 1 addition & 1 deletion src/diagnosticMessages.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Not implemented.": 100,
"Not implemented: {0}": 100,
"Operation is unsafe.": 101,
"User-defined: {0}": 102,
"Feature '{0}' is not enabled.": 103,
Expand Down
5 changes: 3 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2606,8 +2606,9 @@ export class Parser extends DiagnosticEmitter {
if (tn.skip(Token.COMMA)) {
// TODO: default + star, default + members
this.error(
DiagnosticCode.Not_implemented,
tn.range()
DiagnosticCode.Not_implemented_0,
tn.range(),
"Mixed default and named imports"
);
return null;
}
Expand Down
42 changes: 9 additions & 33 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,7 @@ export class Resolver extends DiagnosticEmitter {
);
}
}
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Not_implemented,
node.range
);
}
assert(false);
return null;
}

Expand Down Expand Up @@ -1158,12 +1153,7 @@ export class Resolver extends DiagnosticEmitter {
);
}
}
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Not_implemented,
node.range
);
}
assert(false);
return null;
}

Expand Down Expand Up @@ -1658,13 +1648,14 @@ export class Resolver extends DiagnosticEmitter {
// return this.resolveClass(this.program.readonlyArrayPrototype, [ elementType ]);
// }
this.error(
DiagnosticCode.Not_implemented,
node.range
DiagnosticCode.Not_implemented_0,
node.range,
"Const assertion"
);
return null;
}
default: assert(false);
}
assert(false);
return null;
}

Expand Down Expand Up @@ -1882,12 +1873,7 @@ export class Resolver extends DiagnosticEmitter {
return type;
}
}
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Not_implemented,
node.range
);
}
assert(false);
return null;
}

Expand Down Expand Up @@ -2106,12 +2092,7 @@ export class Resolver extends DiagnosticEmitter {
return this.resolveExpression(left, ctxFlow, ctxType, reportMode);
}
}
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Not_implemented,
node.range
);
}
assert(false);
return null;
}

Expand Down Expand Up @@ -2316,12 +2297,7 @@ export class Resolver extends DiagnosticEmitter {
return assert(this.resolveClass(this.program.arrayPrototype, [ elementType ]));
}
}
if (reportMode == ReportMode.REPORT) {
this.error(
DiagnosticCode.Not_implemented,
node.range
);
}
assert(false);
return null;
}

Expand Down
Loading