On 11/29/17 11:50 PM, Nicholas Wilson wrote:
On Thursday, 30 November 2017 at 04:21:20 UTC, Steven Schveighoffer wrote:
On 11/29/17 10:29 PM, Walter Bright wrote:
Another issue (I should check this again) was doing null checks on
member function calls, which is not necessary since if they're null
it'll seg fault.
Just happened last release.
https://dlang.org/changelog/2.077.0.html#removePreludeAssert
That was specifically for constructors and destructors (i.e.
(cast(Foo)null).__ctor() was the only way to trigger that assert) not
member functions (of classes), which I believe is still part of the
compiler.
Then either the changelog entry is wrong, or the fix was more
encompassing than the author/reviewers thought:
Stevens-MacBook-Pro:testd steves$ cat testprelude.d
struct S
{
int foo() { return 1; }
}
void main()
{
S s;
auto x = s.foo;
}
Stevens-MacBook-Pro:testd steves$ dvm use 2.076.1
Stevens-MacBook-Pro:testd steves$ dmd -vcg-ast testprelude.d
Stevens-MacBook-Pro:testd steves$ cat testprelude.d.cg
import object;
struct S
{
int foo()
{
assert(&this, "null this");
return 1;
}
}
void main()
{
S s = 0;
int x = s.foo();
return 0;
}
RTInfo!(S)
{
enum typeof(null) RTInfo = null;
}
Stevens-MacBook-Pro:testd steves$ dvm use 2.077.0
Stevens-MacBook-Pro:testd steves$ dmd -vcg-ast testprelude.d
Stevens-MacBook-Pro:testd steves$ cat testprelude.d.cg
import object;
struct S
{
int foo()
{
return 1;
}
}
void main()
{
S s = 0;
int x = s.foo();
return 0;
}
RTInfo!(S)
{
enum typeof(null) RTInfo = null;
}
-Steve