Skip to content

Commit

Permalink
Fix internal error when assigning a type to a value (#26517)
Browse files Browse the repository at this point in the history
Fixes an internal error when trying to assign a type to a value inside a
task intent.

Resolves #26511

- [x] full paratest with/without gasnet

[Reviewed by @mppf]
  • Loading branch information
jabraham17 authored Jan 14, 2025
2 parents 8311537 + 07e320d commit a4397d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/resolution/functionResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9175,9 +9175,9 @@ static void moveHaltMoveIsUnacceptable(CallExpr* call) {
} else {
if (lhsSym->hasFlag(FLAG_TYPE_VARIABLE) == false &&
lhsSym->hasFlag(FLAG_MAYBE_TYPE) == false) {
FnSymbol* fn = toFnSymbol(call->parentSymbol);

if (fn->getReturnSymbol() == lhsSym) {
auto fn = toFnSymbol(call->parentSymbol);
if (fn && fn->getReturnSymbol() == lhsSym) {
USR_FATAL(call, "illegal return of type where value is expected");

} else if (lhsSym->hasFlag(FLAG_CHPL__ITER) == true) {
Expand Down
10 changes: 10 additions & 0 deletions test/classes/deitz/types/type_to_value_error_intent.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class C {
var x: int;
}

var c: borrowed C?;

forall 1..10 with (var c = C()) {
}

writeln(c);
1 change: 1 addition & 0 deletions test/classes/deitz/types/type_to_value_error_intent.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type_to_value_error_intent.chpl:7: error: illegal assignment of type to value

0 comments on commit a4397d5

Please sign in to comment.