Skip to content

Commit

Permalink
Fixed more test fails...
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMan committed Nov 16, 2024
1 parent 1f42c4b commit ddb56bb
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 38 deletions.
5 changes: 3 additions & 2 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,8 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
}
else if (p.storageClass & STC.ref_)
{
if (global.params.rvalueRefParam == FeatureState.enabled &&
if (global.params.rvalueRefParam != FeatureState.disabled &&
!(p.storageClass & STC.return_) &&
!arg.isLvalue() &&
targ.isCopyable())
{ /* allow rvalues to be passed to ref parameters by copying
Expand All @@ -3298,7 +3299,7 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
ev = new CommaExp(arg.loc, ev, new VarExp(arg.loc, v));
arg = ev.expressionSemantic(sc);
}
arg = arg.toLvalue(sc, "create `ref` parameter from");
arg = arg.toLvalue(sc, (p.storageClass & STC.return_) ? "create `return ref` parameter from" : "create `ref` parameter from");

// Look for mutable misaligned pointer, etc., in @safe mode
err |= checkUnsafeAccess(sc, arg, false, true);
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2287,8 +2287,8 @@ Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
// default arg must be an lvalue
if (isRefOrOut && !isAuto &&
!(fparam.storageClass & STC.constscoperef) &&
global.params.rvalueRefParam != FeatureState.enabled)
e = e.toLvalue(sc, "create default argument for `ref` / `out` parameter from");
(global.params.rvalueRefParam == FeatureState.disabled || (fparam.storageClass & (STC.out_ | STC.return_))))
e = e.toLvalue(sc, (global.params.rvalueRefParam != FeatureState.disabled) ? "create default argument for `return ref` / `out` parameter from" : "create default argument for `ref` / `out` parameter from");

fparam.defaultArg = e;
return (e.op != EXP.error);
Expand Down
1 change: 1 addition & 0 deletions compiler/test/compilable/reverthelp.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Revertable language changes listed by -revert=name:
=dip1000 revert DIP1000 changes (Scoped Pointers) (https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md)
=intpromote revert integral promotions for unary + - ~ operators
=dtorfields don't destruct fields of partially constructed objects
=rvaluerefparam revert rvalue arguments to ref parameters
----
*/
7 changes: 0 additions & 7 deletions compiler/test/fail_compilation/fail7603a.d

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/fail7603b.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail7603b.d(7): Error: cannot create default argument for `ref` / `out` parameter from constant `true`
fail_compilation/fail7603b.d(7): Error: cannot create default argument for `return ref` / `out` parameter from constant `true`
---
*/
void test(out bool val = true) { }
8 changes: 0 additions & 8 deletions compiler/test/fail_compilation/fail7603c.d

This file was deleted.

10 changes: 0 additions & 10 deletions compiler/test/fail_compilation/fail9773.d

This file was deleted.

10 changes: 2 additions & 8 deletions compiler/test/fail_compilation/fail9891.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail9891.d(13): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `ref int` of parameter `n`
fail_compilation/fail9891.d(18): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `out int` of parameter `n`
fail_compilation/fail9891.d(23): Error: cannot create default argument for `ref` / `out` parameter from expression `prop()` because it is not an lvalue
fail_compilation/fail9891.d(12): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `ref int` of parameter `n`
fail_compilation/fail9891.d(17): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `out int` of parameter `n`
---
*/

Expand All @@ -19,8 +18,3 @@ void f2(out int n = i)
{
++n;
}

void f3(ref int n = prop)
{
++n;
}

0 comments on commit ddb56bb

Please sign in to comment.