From 41133e339d2bd67283313df7479654483888f3d5 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 15 Jul 2021 16:37:30 -0400 Subject: [PATCH 1/6] fix: remove warning 232 Because of tree shaking unused methods or class aren't compiled so there is no need to warn about unimplemented instances. --- src/compiler.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index 4128944f4b..d2b0f99719 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -798,11 +798,6 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } - } else if (functionPrototype.is(CommonFlags.GENERIC)) { - this.warning( - DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, - functionPrototype.identifierNode.range - ); } break; } @@ -820,11 +815,6 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } - } else if (classPrototype.is(CommonFlags.GENERIC)) { - this.warning( - DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, - classPrototype.identifierNode.range - ); } break; } From b958d6628c1066f66c1ad51ab69708b228d6cb3c Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 15 Jul 2021 16:37:30 -0400 Subject: [PATCH 2/6] Revert "fix: remove warning 232" This reverts commit 41133e339d2bd67283313df7479654483888f3d5. --- src/compiler.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler.ts b/src/compiler.ts index d2b0f99719..4128944f4b 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -798,6 +798,11 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } + } else if (functionPrototype.is(CommonFlags.GENERIC)) { + this.warning( + DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, + functionPrototype.identifierNode.range + ); } break; } @@ -815,6 +820,11 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } + } else if (classPrototype.is(CommonFlags.GENERIC)) { + this.warning( + DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, + classPrototype.identifierNode.range + ); } break; } From 80c8120afbbf8edc5fbf62a8d92905fe74ae6130 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 15 Jul 2021 16:51:42 -0400 Subject: [PATCH 3/6] fix: make 232 pendantic --- src/compiler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index 4128944f4b..895a3dc0e7 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -799,7 +799,7 @@ export class Compiler extends DiagnosticEmitter { this.ensureModuleExport(instanceName, instance, prefix); } } else if (functionPrototype.is(CommonFlags.GENERIC)) { - this.warning( + this.pedantic( DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, functionPrototype.identifierNode.range ); @@ -821,7 +821,7 @@ export class Compiler extends DiagnosticEmitter { this.ensureModuleExport(instanceName, instance, prefix); } } else if (classPrototype.is(CommonFlags.GENERIC)) { - this.warning( + this.pedantic( DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, classPrototype.identifierNode.range ); From 5801b884f34a950db83ffbd746327bf7e2bf9cf5 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 15 Jul 2021 17:20:30 -0400 Subject: [PATCH 4/6] fix: add pedantic check --- src/compiler.ts | 6 +++--- tests/compiler/export-generic.json | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index 895a3dc0e7..265d30d41e 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -798,8 +798,8 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } - } else if (functionPrototype.is(CommonFlags.GENERIC)) { - this.pedantic( + } else if (functionPrototype.is(CommonFlags.GENERIC) && this.options.pedantic) { + this.pedantic( DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, functionPrototype.identifierNode.range ); @@ -820,7 +820,7 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } - } else if (classPrototype.is(CommonFlags.GENERIC)) { + } else if (classPrototype.is(CommonFlags.GENERIC) && this.options.pedantic) { this.pedantic( DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, classPrototype.identifierNode.range diff --git a/tests/compiler/export-generic.json b/tests/compiler/export-generic.json index 92e8dd2763..9df2db436e 100644 --- a/tests/compiler/export-generic.json +++ b/tests/compiler/export-generic.json @@ -1,5 +1,6 @@ { "asc_flags": [ + "--pedantic" ], "stderr": [ "AS232: Exported generic function or class has no concrete instances.", From 5e59a4a64eacb3885ed8e6848e3758dbae6554c2 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 15 Jul 2021 17:43:04 -0400 Subject: [PATCH 5/6] chore: fmt --- src/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler.ts b/src/compiler.ts index 265d30d41e..75ff198072 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -799,7 +799,7 @@ export class Compiler extends DiagnosticEmitter { this.ensureModuleExport(instanceName, instance, prefix); } } else if (functionPrototype.is(CommonFlags.GENERIC) && this.options.pedantic) { - this.pedantic( + this.pedantic( DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, functionPrototype.identifierNode.range ); From 679a4563356fd2b63ae43e308717935985abce8e Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Thu, 22 Jul 2021 15:51:26 -0400 Subject: [PATCH 6/6] nit: make separate conditional branch --- src/compiler.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index 75ff198072..9952dce23e 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -798,11 +798,13 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } - } else if (functionPrototype.is(CommonFlags.GENERIC) && this.options.pedantic) { - this.pedantic( - DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, - functionPrototype.identifierNode.range - ); + } else if (functionPrototype.is(CommonFlags.GENERIC)) { + if (this.options.pedantic) { + this.pedantic( + DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, + functionPrototype.identifierNode.range + ); + } } break; } @@ -820,11 +822,13 @@ export class Compiler extends DiagnosticEmitter { } this.ensureModuleExport(instanceName, instance, prefix); } - } else if (classPrototype.is(CommonFlags.GENERIC) && this.options.pedantic) { - this.pedantic( - DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, - classPrototype.identifierNode.range - ); + } else if (classPrototype.is(CommonFlags.GENERIC)) { + if (this.options.pedantic) { + this.pedantic( + DiagnosticCode.Exported_generic_function_or_class_has_no_concrete_instances, + classPrototype.identifierNode.range + ); + } } break; }