Skip to content

Commit

Permalink
Reference feature in not implemented diagnostic (AssemblyScript#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored May 27, 2020
1 parent 5c9cd70 commit 4139a74
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 169 deletions.
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

0 comments on commit 4139a74

Please sign in to comment.