[Issue 5274] Impure function call inside impure function nested inside pure function

2010-11-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5274



--- Comment #3 from Steven Schveighoffer schvei...@yahoo.com 2010-11-29 
07:43:03 PST ---
(In reply to comment #2)

 Maybe you are right, there is no much better error message to be invented 
 here.

Hm... I'd expect a message like:

Error: pure function 'foo.bar' cannot call impure function 'putchar'

But this doesn't seem to be a very critical problem, the line number is
correct, so you can see where the problem is.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5274] Impure function call inside impure function nested inside pure function

2010-11-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5274



--- Comment #4 from Don clugd...@yahoo.com.au 2010-11-29 14:25:47 PST ---
(In reply to comment #3)
 (In reply to comment #2)
 
  Maybe you are right, there is no much better error message to be invented 
  here.
 
 Hm... I'd expect a message like:
 
 Error: pure function 'foo.bar' cannot call impure function 'putchar'

At present, you get that error message if you explicitly mark bar as pure.
But, the existing error message tells you why bar is pure. It's because foo is
pure. This is helpful if there are several levels of nesting: it tells you the
level which was pure.

 
 But this doesn't seem to be a very critical problem, the line number is
 correct, so you can see where the problem is.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5274] Impure function call inside impure function nested inside pure function

2010-11-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5274


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||clugd...@yahoo.com.au
 Resolution||INVALID


--- Comment #1 from Don clugd...@yahoo.com.au 2010-11-24 19:06:38 PST ---
(In reply to comment #0)
 This D2 code is formally correct because bar() is never called:

No, the code is incorrect.
The error message occurs because bar() cannot be compiled.
Think about it -- its mangled name must have 'pure' in it.

The fact that there's no way that the function can actually be called, is
irrelevant: it was marked as pure, but it violates pure.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5274] Impure function call inside impure function nested inside pure function

2010-11-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5274



--- Comment #2 from bearophile_h...@eml.cc 2010-11-24 19:34:49 PST ---
I have not expressed myself well enough, I am sorry. This bug report is a
diagnostic one, it's not a rejects valid. So I agree that this code needs
to be refused at compile time, but is this a good message?

test.d(4): Error: pure function 'foo' cannot call impure function 'putchar'

foo() doesn't contain putchar(), it's bar() that calls it.

I don't know what is a good error message for this situation.
This is a reduced test case:


void foo() {}
pure void bar() {
void spam() {
foo();
}
}
void main() {}


Maybe you are right, there is no much better error message to be invented here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---