Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failure for promotion and named-expression #11225

Open
benharsh opened this issue Sep 24, 2018 · 4 comments
Open

Compilation failure for promotion and named-expression #11225

benharsh opened this issue Sep 24, 2018 · 4 comments

Comments

@benharsh
Copy link
Member

Summary of Problem

The following program fails to compile due to the use of a named-expression in a promoted expression:

proc foo(a:int=1, b:int=2) {
  return a + b;
}

var A = [1,2,3,4,5];
var X = foo(1, b=A); // Compiles and runs successfully.
writeln(X);
var Y = foo(b=A); // Fails to compile
writeln(Y);

The compiler fails with the output:

foo.chpl:8: error: unresolved call 'chpl_iteratorFromForExpr()'
$CHPL_HOME/modules/internal/ChapelIteratorSupport.chpl:217: note: candidates are: chpl_iteratorFromForExpr(ir: _iteratorRecord)
$CHPL_HOME/modules/internal/ChapelIteratorSupport.chpl:225: note:                 chpl_iteratorFromForExpr(arg)
@benharsh
Copy link
Member Author

benharsh commented Sep 24, 2018

@vasslitvinov : here's the bug we briefly emailed about.

Edit: it is not blocking me in any way.

@cassella
Copy link
Contributor

The behavior has changed to

foo.chpl:8: internal error: assertion error [resolution//home/fortytwo/src/chapel/compiler/resolution/wrappers.cpp:2063]

which is

static Symbol* leadingArg(PromotionInfo& promotion, CallExpr* call) {
  int i = promotion.formalToActualOpMod;
  // Operators might have a different number of formals than provided actuals.
  // In this case, the promotedType array access needs to be adjusted to account
  // for the offset.
  for_actuals(actual, call) {
    if (i < 0) {
      i++;
      continue;
    }
    if (promotion.promotedType[i++] != NULL)
      return symbolForActual(actual);
  }

  INT_ASSERT(false); // did not find any promoted things
  return NULL;
}

@bradcray
Copy link
Member

If the assertion is removed, it seems like the behavior is very similar to that in the OP, so maybe not much has changed here... :(

@DanilaFe
Copy link
Contributor

DanilaFe commented Jan 3, 2025

Since Michael mentioned it would be nice to get this working in Dyno, I've double checked that it works (it does!). #26464 locks down the test (though it does not fix the issue in production).

DanilaFe added a commit that referenced this issue Jan 6, 2025
In production, the issue (presumably) persists. However, in Dyno
everything looks like it works as we'd expect. So, locking down the test
case to ensure subsequent changes to Dyno don't break it.

Trivial, will not be reviewed.

## Testing
- [x] dyno tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants