Skip to content

Commit

Permalink
Merge pull request CyberShadow#20 from funkwerk/bugfix19
Browse files Browse the repository at this point in the history
Change in 1.2.0 breaks some const usage
  • Loading branch information
belka-ew authored Jan 11, 2018
2 parents 90e100a + 4df5c35 commit 5060ba5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ os:
language: d

d:
- dmd-2.078.0
- dmd-2.077.1
- dmd-2.076.1
- dmd-2.075.1
- dmd-2.074.1

env:
matrix:
Expand Down
31 changes: 27 additions & 4 deletions src/accessors.d
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ template GenerateReader(string name, alias field)

static if (needToDup)
{
return format("%s%s final @property auto %s() %s"
~ "{ return [] ~ this.%s; }",
return format("%s%s final @property auto %s() inout %s"
~ "{ return null ~ this.%s; }",
visibility, getModifiers!field, accessorName, attributesString, name);
}
else static if (isStatic!field)
Expand Down Expand Up @@ -183,8 +183,8 @@ template GenerateReader(string name, alias field)
"public static final @property auto foo() " ~
"@nogc nothrow @safe { return this.foo; }");
static assert(GenerateReader!("foo", intArrayValue) ==
"public static final @property auto foo() nothrow @safe "
~ "{ return [] ~ this.foo; }");
"public static final @property auto foo() inout nothrow @safe "
~ "{ return null ~ this.foo; }");
}

template GenerateRefReader(string name, alias field)
Expand Down Expand Up @@ -888,3 +888,26 @@ unittest
static assert(is(typeof({ S.foo = 8; })));
assert(S.bar == 6);
}

unittest
{
struct Thing
{
@Read
private int[] content_;

mixin(GenerateFieldAccessors);
}

class User
{
void helper(const int[] content)
{
}

void doer(const Thing thing)
{
helper(thing.content);
}
}
}

0 comments on commit 5060ba5

Please sign in to comment.