From 8ba9f7e17c5d7049d206164b1093ca5eba40b6e5 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 26 Jan 2021 15:34:33 -0500 Subject: [PATCH] Add compilation error for case expected to change See issue #16508. In the future we would like 'this.type' to convey the type information for a typeless field as in record TypelessField { var field; proc init() { /* this.type.field indicates int in the below case */ } } type TypelessFieldInt = TypelessField(int); var b: TypelessFieldInit; --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 17 +++-------------- modules/packages/Sort.chpl | 9 ++++++--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index d9bdba5b2021..a689ede17a96 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -11002,22 +11002,11 @@ static CallExpr* createGenericRecordVarDefaultInitCall(Symbol* val, } else { appendExpr = new SymExpr(e->value); } - } else if (isGenericField && hasDefault == false) { - // Create a temporary to pass for the fully-generic field (e.g. "var x;") - VarSymbol* temp = newTemp("default_field_temp", e->value->typeInfo()); - CallExpr* tempCall = new CallExpr(PRIM_DEFAULT_INIT_VAR, temp, e->value); - - call->insertBefore(new DefExpr(temp)); - call->insertBefore(tempCall); - resolveExpr(tempCall->get(2)); - resolveExpr(tempCall); - appendExpr = new SymExpr(temp); - - } else if (isGenericField && hasDefault == true) { + } else if (isGenericField) { USR_FATAL_CONT(call, "this default-initialization is not yet supported"); - USR_PRINT(field, "field '%s' is declared with a generic type " - "and also a default value", + USR_PRINT(field, "field '%s' is declared with a generic type", field->name); + USR_PRINT(field, "consider separately declaraing a type field"); USR_STOP(); } else { diff --git a/modules/packages/Sort.chpl b/modules/packages/Sort.chpl index 926f3f9f7fc4..a9c313c3707e 100644 --- a/modules/packages/Sort.chpl +++ b/modules/packages/Sort.chpl @@ -263,13 +263,16 @@ module Sort { argument when no comparator is passed to a sort function */ const defaultComparator: DefaultComparator; +defaultComparator = new DefaultComparator(); /* - Instance of :record:`ReverseComparator`. Pass this as the ``comparator=`` - argument of a sort function to reverse the sort order. + Instance of :record:`ReverseComparator` that reverses the default comparator. + Pass this as the ``comparator=`` + argument of a sort function to reverse the default sort order. */ -const reverseComparator: ReverseComparator(DefaultComparator); +const reverseComparator: ReverseComparator; +reverseComparator = new ReverseComparator(); /* Private methods */