Skip to content

Commit

Permalink
Respond to review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mppf committed Feb 24, 2020
1 parent 76356ec commit 9f2acec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
36 changes: 18 additions & 18 deletions compiler/main/checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ static FnSymbol* findUserInitEq(AggregateType* at) {
for_alive_in_Vec(FnSymbol, fn, gFnSymbols) {
if (fn->name == astrInitEquals &&
!fn->hasFlag(FLAG_COMPILER_GENERATED) &&
fn->numFormals() >= 2) {
fn->numFormals() >= 1) {
ArgSymbol* lhs = fn->getFormal(1);
Type* t = lhs->getValType();
if (t == at)
Expand Down Expand Up @@ -740,45 +740,45 @@ checkDefaultInitEqAndAssign()
if (ts->hasFlag(FLAG_EXTERN))
continue; // can't make init= for extern types today anyway
if (!isRecord(ts->type) && !isUnion(ts->type))
continue; // can't make init= for non-records today anyway
continue; // can't make init= for non-records non-unions today anyway

AggregateType* at = toAggregateType(ts->type);
bool defaultInitEq = ts->hasFlag(FLAG_TYPE_DEFAULT_INIT_EQUAL);
bool customInitEq = ts->hasFlag(FLAG_TYPE_CUSTOM_INIT_EQUAL);
bool defaultAssign = ts->hasFlag(FLAG_TYPE_DEFAULT_ASSIGN);
bool customAssign = ts->hasFlag(FLAG_TYPE_CUSTOM_ASSIGN);
if (defaultInitEq && customAssign) {
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default init= "
"but has a custom = function. "
"Please add an init= method",
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default 'init=' "
"but has a custom '=' function. "
"Please add an 'init=' method",
toString(ts->type));
if (FnSymbol* userAssign = findUserAssign(at))
USR_PRINT(userAssign, "= for '%s' defined here", toString(ts->type));
USR_PRINT(userAssign, "'=' for '%s' defined here", toString(ts->type));
}
if (defaultInitEq && customInitEq) {
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default init= "
"but also has a custom init= method. "
"Please add an init= method with the same RHS type",
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default 'init=' "
"but also has a custom 'init=' method. "
"Please add an 'init=' method with the same RHS type",
toString(ts->type));
if (FnSymbol* userInitEq = findUserInitEq(at))
USR_PRINT(userInitEq, "init= for '%s' defined here", toString(ts->type));
USR_PRINT(userInitEq, "'init=' for '%s' defined here", toString(ts->type));
}

if (customInitEq && defaultAssign) {
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default = "
"but has a custom init= method. "
"Please add a = function.",
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default '=' "
"but has a custom 'init=' method. "
"Please add a '=' function.",
toString(ts->type));
if (FnSymbol* userInitEq = findUserInitEq(at))
USR_PRINT(userInitEq, "init= for '%s' defined here", toString(ts->type));
USR_PRINT(userInitEq, "'init=' for '%s' defined here", toString(ts->type));
}
if (defaultAssign && customAssign) {
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default = "
"but also has a custom = function. "
"Please add a = function with the same RHS type.",
USR_FATAL_CONT(ts, "Type '%s' uses compiler-generated default '=' "
"but also has a custom '=' function. "
"Please add a '=' function with the same RHS type.",
toString(ts->type));
if (FnSymbol* userAssign = findUserAssign(at))
USR_PRINT(userAssign, "= for '%s' defined here", toString(ts->type));
USR_PRINT(userAssign, "'=' for '%s' defined here", toString(ts->type));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/types/records/ferguson/init-eq-assign-checks.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
init-eq-assign-checks.chpl:1: error: Type 'InitEqOnly' uses compiler-generated default = but has a custom init= method. Please add a = function.
init-eq-assign-checks.chpl:2: note: init= for 'InitEqOnly' defined here
init-eq-assign-checks.chpl:4: error: Type 'AssignOnly' uses compiler-generated default init= but has a custom = function. Please add an init= method
init-eq-assign-checks.chpl:5: note: = for 'AssignOnly' defined here
init-eq-assign-checks.chpl:1: error: Type 'InitEqOnly' uses compiler-generated default '=' but has a custom 'init=' method. Please add a '=' function.
init-eq-assign-checks.chpl:2: note: 'init=' for 'InitEqOnly' defined here
init-eq-assign-checks.chpl:4: error: Type 'AssignOnly' uses compiler-generated default 'init=' but has a custom '=' function. Please add an 'init=' method
init-eq-assign-checks.chpl:5: note: '=' for 'AssignOnly' defined here
4 changes: 2 additions & 2 deletions test/types/records/ferguson/init-eq-other-only.good
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
init-eq-other-only.chpl:1: error: Type 'InitEqOtherOnly' uses compiler-generated default init= but also has a custom init= method. Please add an init= method with the same RHS type
init-eq-other-only.chpl:4: note: init= for 'InitEqOtherOnly' defined here
init-eq-other-only.chpl:1: error: Type 'InitEqOtherOnly' uses compiler-generated default 'init=' but also has a custom 'init=' method. Please add an 'init=' method with the same RHS type
init-eq-other-only.chpl:4: note: 'init=' for 'InitEqOtherOnly' defined here

0 comments on commit 9f2acec

Please sign in to comment.