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

Bad error message for calling a method on a field of a promoted expression #14408

Closed
ben-albrecht opened this issue Nov 8, 2019 · 2 comments · Fixed by #14411
Closed

Bad error message for calling a method on a field of a promoted expression #14408

ben-albrecht opened this issue Nov 8, 2019 · 2 comments · Fixed by #14411

Comments

@ben-albrecht
Copy link
Member

Summary of Problem

I encountered an internal module error message when I called a method (lines()) on a field (stdout) of a promoted expression of objects (subprocess).

I have not attempted to distill the reproducer past this, so I am not confident in how generally this error message applies.

I ran into this when modifying my interface of f() from f(s: [] string) -> f(s: string)), and started getting unintentional promotion.

Steps to Reproduce

Source Code:

use Spawn;

proc f(s: string) {
  var p = spawnshell(s, stdout=PIPE, stderr=PIPE);
  p.communicate();
  return p;
}

var p = f(['ls', '-l']);
var lines = p.stdout.lines(); // <-- offending expression

Compile command:

> chpl Lines.chpl
$CHPL_HOME/modules/internal/ChapelIteratorSupport.chpl:283: error: illegal return of value where type is expected

> chpl Lines.chpl --devel
$CHPL_HOME/modules/internal/ChapelIteratorSupport.chpl:278: In function 'chpl_iteratorShapeStaticTypeOrVoid':
$CHPL_HOME/modules/internal/ChapelIteratorSupport.chpl:283: error: illegal return of value where type is expected
$CHPL_HOME/modules/internal/ChapelIteratorSupport.chpl:166: Function 'chpl_iteratorShapeStaticTypeOrVoid' instantiated as: chpl_iteratorShapeStaticTypeOrVoid(type ir = _ir_lines__ref_channel_F_dynamic_T)

Configuration Information

  • Output of chpl --version: chpl version 1.21.0 pre-release (f3e74adea4)
@bradcray
Copy link
Member

bradcray commented Nov 8, 2019

It looks to me as though the none on ChapelIteratorSupport.chpl:283 should be nothing. Does making that change help? (I don't have a clean copy of master to test with quickly). It looks like the callsite is correctly expecting nothing to come back as the sentinel.

If PR-ing this fix, we should either change these nothings back to void or change the procedure name to say Nothing rather than Void.

(I'm guessing this code path isn't tested or that @daviditen would've run into this problem when making the change in ed48984).

@bradcray
Copy link
Member

bradcray commented Nov 8, 2019

OK, I beat you to it: Making the change gives the following error message:

testit2.chpl:10: error: creating an array of arrays using a for- or forall-expression is not supported, except when using a for-expression over a range

which I think is correct (i.e., I think your code is trying to do this and that we don't currently support it).

@bradcray bradcray self-assigned this Nov 8, 2019
bradcray added a commit that referenced this issue Nov 11, 2019
Fix a simple bug that had crept into ChapelIteratorSupport

[reviewed by @mppf and @daviditen]

This fixes a bug that crept into ChapelIteratorSupport in which we
were returning the 'none' value in a function that is supposed to
return types. Here, rather than changing the type into 'nothing', I
changed it back to the original 'void' since (a) it matches the
original function name's statement of what it's doing and (b) the type
is used as a sentinel value, so it doesn't particularly matter that
it's a type that has no values.

Resolves #14408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants