Skip to content

Commit 4139a74

Browse files
authored
Reference feature in not implemented diagnostic (#1295)
1 parent 5c9cd70 commit 4139a74

File tree

9 files changed

+178
-169
lines changed

9 files changed

+178
-169
lines changed

src/builtins.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,8 +2838,9 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
28382838
}
28392839
}
28402840
compiler.error(
2841-
DiagnosticCode.Not_implemented,
2842-
ctx.reportNode.typeArgumentsRange
2841+
DiagnosticCode.Operation_0_cannot_be_applied_to_type_1,
2842+
ctx.reportNode.typeArgumentsRange,
2843+
"assert", compiler.currentType.toString()
28432844
);
28442845
return abort;
28452846
}

src/compiler.ts

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,10 +1531,12 @@ export class Compiler extends DiagnosticEmitter {
15311531

15321532
// Just prepended allocation is dropped when returning non-'this'
15331533
if (flow.is(FlowFlags.MAY_RETURN_NONTHIS)) {
1534-
this.pedantic(
1535-
DiagnosticCode.Explicitly_returning_constructor_drops_this_allocation,
1536-
instance.identifierNode.range
1537-
);
1534+
if (this.options.pedantic) {
1535+
this.pedantic(
1536+
DiagnosticCode.Explicitly_returning_constructor_drops_this_allocation,
1537+
instance.identifierNode.range
1538+
);
1539+
}
15381540
}
15391541
}
15401542

@@ -2107,8 +2109,9 @@ export class Compiler extends DiagnosticEmitter {
21072109
case NodeKind.TYPEDECLARATION: {
21082110
// TODO: integrate inner type declaration into flow
21092111
this.error(
2110-
DiagnosticCode.Not_implemented,
2111-
statement.range
2112+
DiagnosticCode.Not_implemented_0,
2113+
statement.range,
2114+
"Inner type alias"
21122115
);
21132116
stmt = module.unreachable();
21142117
break;
@@ -2182,8 +2185,9 @@ export class Compiler extends DiagnosticEmitter {
21822185
var labelNode = statement.label;
21832186
if (labelNode) {
21842187
this.error(
2185-
DiagnosticCode.Not_implemented,
2186-
labelNode.range
2188+
DiagnosticCode.Not_implemented_0,
2189+
labelNode.range,
2190+
"Break label"
21872191
);
21882192
return module.unreachable();
21892193
}
@@ -2216,8 +2220,9 @@ export class Compiler extends DiagnosticEmitter {
22162220
var label = statement.label;
22172221
if (label) {
22182222
this.error(
2219-
DiagnosticCode.Not_implemented,
2220-
label.range
2223+
DiagnosticCode.Not_implemented_0,
2224+
label.range,
2225+
"Continue label"
22212226
);
22222227
return module.unreachable();
22232228
}
@@ -2581,8 +2586,9 @@ export class Compiler extends DiagnosticEmitter {
25812586
statement: ForOfStatement
25822587
): ExpressionRef {
25832588
this.error(
2584-
DiagnosticCode.Not_implemented,
2585-
statement.range
2589+
DiagnosticCode.Not_implemented_0,
2590+
statement.range,
2591+
"Iterators"
25862592
);
25872593
return this.module.unreachable();
25882594
}
@@ -2915,8 +2921,9 @@ export class Compiler extends DiagnosticEmitter {
29152921
// TODO: can't yet support something like: try { return ... } finally { ... }
29162922
// worthwhile to investigate lowering returns to block results (here)?
29172923
this.error(
2918-
DiagnosticCode.Not_implemented,
2919-
statement.range
2924+
DiagnosticCode.Not_implemented_0,
2925+
statement.range,
2926+
"Exceptions"
29202927
);
29212928
return this.module.unreachable();
29222929
}
@@ -3453,10 +3460,7 @@ export class Compiler extends DiagnosticEmitter {
34533460
break;
34543461
}
34553462
default: {
3456-
this.error(
3457-
DiagnosticCode.Not_implemented,
3458-
expression.range
3459-
);
3463+
assert(false);
34603464
expr = this.module.unreachable();
34613465
}
34623466
}
@@ -3782,8 +3786,9 @@ export class Compiler extends DiagnosticEmitter {
37823786
// }
37833787
// }
37843788
this.error(
3785-
DiagnosticCode.Not_implemented,
3786-
expression.range
3789+
DiagnosticCode.Not_implemented_0,
3790+
expression.range,
3791+
"Const assertion"
37873792
);
37883793
return this.module.unreachable();
37893794
}
@@ -4312,8 +4317,9 @@ export class Compiler extends DiagnosticEmitter {
43124317
case TypeKind.ANYREF: {
43134318
// TODO: ref.eq
43144319
this.error(
4315-
DiagnosticCode.Not_implemented,
4316-
expression.range
4320+
DiagnosticCode.Not_implemented_0,
4321+
expression.range,
4322+
"ref.eq instruction"
43174323
);
43184324
expr = module.unreachable();
43194325
break;
@@ -4412,8 +4418,9 @@ export class Compiler extends DiagnosticEmitter {
44124418
case TypeKind.ANYREF: {
44134419
// TODO: !ref.eq
44144420
this.error(
4415-
DiagnosticCode.Not_implemented,
4416-
expression.range
4421+
DiagnosticCode.Not_implemented_0,
4422+
expression.range,
4423+
"ref.eq instruction"
44174424
);
44184425
expr = module.unreachable();
44194426
break;
@@ -5950,10 +5957,7 @@ export class Compiler extends DiagnosticEmitter {
59505957
break;
59515958
}
59525959
default: {
5953-
this.error(
5954-
DiagnosticCode.Not_implemented,
5955-
expression.range
5956-
);
5960+
assert(false);
59575961
return this.module.unreachable();
59585962
}
59595963
}
@@ -6154,10 +6158,7 @@ export class Compiler extends DiagnosticEmitter {
61546158
}
61556159
}
61566160
}
6157-
this.error(
6158-
DiagnosticCode.Not_implemented,
6159-
valueExpression.range
6160-
);
6161+
assert(false);
61616162
return module.unreachable();
61626163
}
61636164

@@ -6627,10 +6628,7 @@ export class Compiler extends DiagnosticEmitter {
66276628
false
66286629
));
66296630
}
6630-
this.error(
6631-
DiagnosticCode.Not_implemented,
6632-
expression.expression.range
6633-
);
6631+
assert(false);
66346632
return this.module.unreachable();
66356633
}
66366634

@@ -6659,8 +6657,9 @@ export class Compiler extends DiagnosticEmitter {
66596657
var hasRest = signature.hasRest;
66606658
if (hasRest) {
66616659
this.error(
6662-
DiagnosticCode.Not_implemented,
6663-
reportNode.range
6660+
DiagnosticCode.Not_implemented_0,
6661+
reportNode.range,
6662+
"Rest parameters"
66646663
);
66656664
return false;
66666665
}
@@ -8148,8 +8147,9 @@ export class Compiler extends DiagnosticEmitter {
81488147
if (target.parent != flow.parentFunction) {
81498148
// TODO: closures
81508149
this.error(
8151-
DiagnosticCode.Not_implemented,
8152-
expression.range
8150+
DiagnosticCode.Not_implemented_0,
8151+
expression.range,
8152+
"Closures"
81538153
);
81548154
return module.unreachable();
81558155
}
@@ -8212,10 +8212,7 @@ export class Compiler extends DiagnosticEmitter {
82128212
return module.i32(index);
82138213
}
82148214
}
8215-
this.error(
8216-
DiagnosticCode.Not_implemented,
8217-
expression.range
8218-
);
8215+
assert(false);
82198216
return this.module.unreachable();
82208217
}
82218218

@@ -8465,13 +8462,17 @@ export class Compiler extends DiagnosticEmitter {
84658462
assert(!implicitlyNegate);
84668463
return this.compileObjectLiteral(<ObjectLiteralExpression>expression, contextualType);
84678464
}
8468-
// case LiteralKind.REGEXP:
8465+
case LiteralKind.REGEXP: {
8466+
this.error(
8467+
DiagnosticCode.Not_implemented_0,
8468+
expression.range,
8469+
"Regular expressions"
8470+
);
8471+
this.currentType = contextualType;
8472+
return module.unreachable();
8473+
}
84698474
}
8470-
this.error(
8471-
DiagnosticCode.Not_implemented,
8472-
expression.range
8473-
);
8474-
this.currentType = contextualType;
8475+
assert(false);
84758476
return module.unreachable();
84768477
}
84778478

@@ -9318,10 +9319,7 @@ export class Compiler extends DiagnosticEmitter {
93189319
return module.unreachable();
93199320
}
93209321
}
9321-
this.error(
9322-
DiagnosticCode.Not_implemented,
9323-
expression.range
9324-
);
9322+
assert(false);
93259323
return module.unreachable();
93269324
}
93279325

src/diagnosticMessages.generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/** Enum of available diagnostic codes. */
99
export enum DiagnosticCode {
10-
Not_implemented = 100,
10+
Not_implemented_0 = 100,
1111
Operation_is_unsafe = 101,
1212
User_defined_0 = 102,
1313
Feature_0_is_not_enabled = 103,
@@ -180,7 +180,7 @@ export enum DiagnosticCode {
180180
/** Translates a diagnostic code to its respective string. */
181181
export function diagnosticCodeToString(code: DiagnosticCode): string {
182182
switch (code) {
183-
case 100: return "Not implemented.";
183+
case 100: return "Not implemented: {0}";
184184
case 101: return "Operation is unsafe.";
185185
case 102: return "User-defined: {0}";
186186
case 103: return "Feature '{0}' is not enabled.";

src/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Not implemented.": 100,
2+
"Not implemented: {0}": 100,
33
"Operation is unsafe.": 101,
44
"User-defined: {0}": 102,
55
"Feature '{0}' is not enabled.": 103,

src/parser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,8 +2606,9 @@ export class Parser extends DiagnosticEmitter {
26062606
if (tn.skip(Token.COMMA)) {
26072607
// TODO: default + star, default + members
26082608
this.error(
2609-
DiagnosticCode.Not_implemented,
2610-
tn.range()
2609+
DiagnosticCode.Not_implemented_0,
2610+
tn.range(),
2611+
"Mixed default and named imports"
26112612
);
26122613
return null;
26132614
}

src/resolver.ts

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,12 +1034,7 @@ export class Resolver extends DiagnosticEmitter {
10341034
);
10351035
}
10361036
}
1037-
if (reportMode == ReportMode.REPORT) {
1038-
this.error(
1039-
DiagnosticCode.Not_implemented,
1040-
node.range
1041-
);
1042-
}
1037+
assert(false);
10431038
return null;
10441039
}
10451040

@@ -1158,12 +1153,7 @@ export class Resolver extends DiagnosticEmitter {
11581153
);
11591154
}
11601155
}
1161-
if (reportMode == ReportMode.REPORT) {
1162-
this.error(
1163-
DiagnosticCode.Not_implemented,
1164-
node.range
1165-
);
1166-
}
1156+
assert(false);
11671157
return null;
11681158
}
11691159

@@ -1658,13 +1648,14 @@ export class Resolver extends DiagnosticEmitter {
16581648
// return this.resolveClass(this.program.readonlyArrayPrototype, [ elementType ]);
16591649
// }
16601650
this.error(
1661-
DiagnosticCode.Not_implemented,
1662-
node.range
1651+
DiagnosticCode.Not_implemented_0,
1652+
node.range,
1653+
"Const assertion"
16631654
);
16641655
return null;
16651656
}
1666-
default: assert(false);
16671657
}
1658+
assert(false);
16681659
return null;
16691660
}
16701661

@@ -1882,12 +1873,7 @@ export class Resolver extends DiagnosticEmitter {
18821873
return type;
18831874
}
18841875
}
1885-
if (reportMode == ReportMode.REPORT) {
1886-
this.error(
1887-
DiagnosticCode.Not_implemented,
1888-
node.range
1889-
);
1890-
}
1876+
assert(false);
18911877
return null;
18921878
}
18931879

@@ -2106,12 +2092,7 @@ export class Resolver extends DiagnosticEmitter {
21062092
return this.resolveExpression(left, ctxFlow, ctxType, reportMode);
21072093
}
21082094
}
2109-
if (reportMode == ReportMode.REPORT) {
2110-
this.error(
2111-
DiagnosticCode.Not_implemented,
2112-
node.range
2113-
);
2114-
}
2095+
assert(false);
21152096
return null;
21162097
}
21172098

@@ -2316,12 +2297,7 @@ export class Resolver extends DiagnosticEmitter {
23162297
return assert(this.resolveClass(this.program.arrayPrototype, [ elementType ]));
23172298
}
23182299
}
2319-
if (reportMode == ReportMode.REPORT) {
2320-
this.error(
2321-
DiagnosticCode.Not_implemented,
2322-
node.range
2323-
);
2324-
}
2300+
assert(false);
23252301
return null;
23262302
}
23272303

0 commit comments

Comments
 (0)