diff --git a/compiler/passes/initializerRules.cpp b/compiler/passes/initializerRules.cpp index f470ab55e8ba..abcca78e2071 100644 --- a/compiler/passes/initializerRules.cpp +++ b/compiler/passes/initializerRules.cpp @@ -513,7 +513,10 @@ static InitNormalize preNormalize(AggregateType* at, } else if (isSuperInit(callExpr) == true) { Expr* next = callExpr->next; - INT_ASSERT(state.isPhase0() == true); + if (state.isPhase0() != true) { + USR_FATAL(callExpr, + "duplicate use of 'super.init()' in initializer, this should only be called once"); + } state.completePhase0(callExpr); if (at->isRecord() == true) { diff --git a/test/classes/initializers/inheritance/duplicate-super-init.chpl b/test/classes/initializers/inheritance/duplicate-super-init.chpl new file mode 100644 index 000000000000..68b9ab0d2175 --- /dev/null +++ b/test/classes/initializers/inheritance/duplicate-super-init.chpl @@ -0,0 +1,11 @@ +class P { } +class C: P { + proc init() { + super.init(); + super.init(); + } +} + +proc main() { + var c = new C(); +} diff --git a/test/classes/initializers/inheritance/duplicate-super-init.good b/test/classes/initializers/inheritance/duplicate-super-init.good new file mode 100644 index 000000000000..2ee8aec2b7fe --- /dev/null +++ b/test/classes/initializers/inheritance/duplicate-super-init.good @@ -0,0 +1,2 @@ +duplicate-super-init.chpl:3: In initializer: +duplicate-super-init.chpl:5: error: duplicate use of 'super.init()' in initializer, this should only be called once