Issue 6902 - Different "pure nothrow int()" types #498

Merged
merged 2 commits into from Nov 14, 2011

3 participants

@9rnsr
D Programming Language member

While the semantic analysis of function body, we should not do fd->type->semantic(), even if the type inference is necessary.
Because the result of safe/pure/nothrow inference should apply BEFORE fd->type->semantic().

To fix phobos unit test breaking in Windows, we should apply phobos/pull/322 phobos/pull/326 at the same time.

requires: phobos git://github.com/9rnsr/phobos.git fix6902

@klickverbot klickverbot commented on the diff Nov 7, 2011
src/func.c
@@ -1290,7 +1290,7 @@ void FuncDeclaration::semantic3(Scope *sc)
if (!type->nextOf())
{
((TypeFunction *)type)->next = Type::tvoid;
- type = type->semantic(loc, sc);
+ //type = type->semantic(loc, sc);
@klickverbot
D Programming Language member

Could you maybe add a comment (e.g. containing the bug id) as to why this is commented out, or remove the line altogether? Maybe it's just a pet peeve of mine, but I find it highly irritating to stumble across lines which have seemingly been commented out at random when reading a piece of unknown code. Thanks!

@9rnsr
D Programming Language member
9rnsr added a note Nov 7, 2011

Added issue number. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@klickverbot klickverbot commented on the diff Nov 7, 2011
src/statement.c
@@ -3618,7 +3618,7 @@ Statement *ReturnStatement::semantic(Scope *sc)
tf->isref = FALSE; // return by value
}
tf->next = exp->type;
- fd->type = tf->semantic(loc, sc);
+ //fd->type = tf->semantic(loc, sc);
@klickverbot
D Programming Language member

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@9rnsr
D Programming Language member

To @WalterBright
I'd like to merge this pull as soon as possible. The auto tester result in Windows is still breaking by bug 6902.
Why do not you merge this?

@WalterBright WalterBright merged commit 3af7624 into dlang:master Nov 14, 2011
@WalterBright
D Programming Language member

Pulling this resulted in the error:

std\traits.d(404): Error: static assert (35u == cast(FunctionAttribute)0u) is false

while running the Phobos unittests.

@9rnsr
D Programming Language member

You should merge phobos/pull/326 at the same time.
I already merged it now, then you can pull it.

@WalterBright
D Programming Language member

Folded it in, testing now.

@MartinNowak
D Programming Language member

This pull does add inferred 'pure nothrow' to the type mangling.
http://comments.gmane.org/gmane.comp.lang.d.dmd.devel/2215

IMHO the real issue is that attribute inference makes the mangled
name non-bijective to the actual type.
This can be fixed in two ways.
Either by separating inferred attributes from declared attributes
and fixing the types merging or by strictly propagating inferred
attributes to the mangling.

This pull goes the second route but adds some inconsistencies.

void foo()() {}

auto curry(alias fun)()
{
return fun();
}

// pure nothrow @safe void bug.curry!(void bug.foo!().foo()).curry()
// !!! outer function is pure, inner is not !!!
alias curry!(foo!()) f;

@9rnsr
D Programming Language member

I think .mangleof property should return the actual value (based on the real type).
Otherwise, we cannot guarantee the pure/nothrow/safe attributes in ABI level.

But, to realize it dmd should implement full deferred semantic mechanism.
It would run its semantic3() with getting .mangleof property, even if a target function declaration is in module level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment