Bug 20507 – Debug statements affect inference of templated functions attributes

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-15T15:32:46Z
Last change time
2020-01-16T00:49:37Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2020-01-15T15:32:46Z
debug statements are allowed to violate @safe, pure, @nogc and nothrow (allthough the latter is not implemented right now). But they influence the attribute interference: ---------------------------------------------- void main() pure /* nothrow */ @safe @nogc { debug foo(); bar!()(); } void foo() @system { // Just to be sure its neither @nogc, pure or nothrow __gshared int counter = 0; if (counter++) throw new Exception(new immutable(char)[counter]); } void bar()() { debug foo(); } ---------------------------------------------- ..\debugging.d(4): Error: @safe function D main cannot call @system function debugging.bar!().bar ..\debugging.d(16): debugging.bar!().bar is declared here ..\debugging.d(4): Error: @nogc function D main cannot call non-@nogc function debugging.bar!().bar ---------------------------------------------- The debug statement caused bar to become @system, non-@nogc and non-nothrow.
Comment #1 by dlang-bot — 2020-01-15T15:38:28Z
@MoonlightSentinel created dlang/dmd pull request #10726 "Fix Issue 20507 - Debug statements affect inference..." fixing this issue: - Fix Issue 20507 - Debug statements affect inference... ...of templated functions attributes. This was caused by marking the function as @system/non-@nogc/non-nothrow BEFORE checking whether the statement is inside an debug statement / block https://github.com/dlang/dmd/pull/10726
Comment #2 by dlang-bot — 2020-01-16T00:49:37Z
dlang/dmd pull request #10726 "Fix Issue 20507 - Debug statements affect inference..." was merged into master: - a7750e0a949f5f3183aecd5a3c9943e19078f6f6 by MoonlightSentinel: Fix Issue 20507 - Debug statements affect inference... ...of templated functions attributes. This was caused by marking the function as @system/non-@nogc/non-nothrow BEFORE checking whether the statement is inside an debug statement / block https://github.com/dlang/dmd/pull/10726