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
Issue 9230 - Incorrect implicit immutable conversion occurs in pure function #1418
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3954,7 +3954,9 @@ Statement *ReturnStatement::semantic(Scope *sc) | |
} | ||
else if (tbret->ty != Tvoid) | ||
{ | ||
if (fd->isPureBypassingInference() == PUREstrong && | ||
assert(fd->type->ty == Tfunction); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function still has to be pure, no? Was this check moved somewhere else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ouch, it's my mistake. We should keep the check whether |
||
TypeFunction *tf = (TypeFunction *)fd->type; | ||
if (!tf->hasMutableIndirectionParams() && | ||
!exp->type->implicitConvTo(tret) && | ||
exp->type->invariantOf()->implicitConvTo(tret)) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/test9230.d(9): Error: cannot implicitly convert expression (s) of type const(char[]) to string | ||
--- | ||
*/ | ||
|
||
string foo(in char[] s) pure { | ||
return s; // | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/PUREstring/PUREstrong ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.