Issue 9230 - Incorrect implicit immutable conversion occurs in pure function #1418

Merged
merged 2 commits into from Dec 28, 2012

2 participants

@9rnsr
D Programming Language member

http://d.puremagic.com/issues/show_bug.cgi?id=9230

hasMutableIndirectionParams() is based on the old TypeFunction::purityLevel() (before fixing issue 8408). So its result is consistent with TypeFunction::purityLevel() != PUREstrong in 2.060. Then it fixes the regression.

@9rnsr 9rnsr fix Issue 9230 - Incorrect implicit immutable conversion occurs in pu…
…re function

`hasMutableIndirectionParams()` is based on the old `TypeFunction::purityLevel()` (before fixing issue 8408). So its result is consistent with `TypeFunction::purityLevel() != PUREstrong` in 2.060. Then it *fixes* the regression.
afa7a54
@yebblies yebblies and 1 other commented on an outdated diff Dec 28, 2012
@@ -5828,6 +5828,67 @@ void TypeFunction::purityLevel()
}
}
+/********************************************
+ * FIXME: This function is a workaround for fixing Bugzilla 9210.
+ * In 2.061, TypeFunction::purityLevel() improved to make more functions
+ * strong purity, but immutable conversion on return statemet had broken by that.
+ * Because, it is essentially unrelated to PUREstring. This function is
@yebblies
D Programming Language member

s/PUREstring/PUREstrong ?

@9rnsr
D Programming Language member
9rnsr added a note Dec 28, 2012

Will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yebblies yebblies commented on the diff Dec 28, 2012
src/statement.c
@@ -3954,7 +3954,9 @@ Statement *ReturnStatement::semantic(Scope *sc)
}
else if (tbret->ty != Tvoid)
{
- if (fd->isPureBypassingInference() == PUREstrong &&
@yebblies
D Programming Language member

The function still has to be pure, no? Was this check moved somewhere else?

@9rnsr
D Programming Language member
9rnsr added a note Dec 28, 2012

Ouch, it's my mistake. We should keep the check whether fd is really a pure function or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@9rnsr 9rnsr Fixed the bug pointed out by Daniel Murphy.
Also updated test cases. By a recent change in 2.061 (4b2767e), direct returning of NewExp sometimes avoids immutable implicit conversion. So, test5081 should return mutable array values through local variables.
000f02e
@9rnsr
D Programming Language member

Updated.

@WalterBright WalterBright merged commit c42d35b into dlang:master Dec 28, 2012

1 check passed

Details default Pass: 10
@9rnsr 9rnsr added a commit to 9rnsr/dmd that referenced this pull request Feb 5, 2013
@9rnsr 9rnsr Revert 9rnsr/fix9230 and 9rnsr/fix8408
- Revert "Merge pull request #1418 from 9rnsr/fix9230"

  This reverts commit c42d35b, reversing
  changes made to 9f2d9ea.

- Revert "Merge pull request #1110 from 9rnsr/fix8408"

  This reverts commit b6a8093, reversing
  changes made to 3b06132.
b65d12a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment