D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6690 - Using lazy parameter should be inferred as @safe
Summary: Using lazy parameter should be inferred as @safe
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
: 6328 (view as issue list)
Depends on:
Blocks:
 
Reported: 2011-09-18 15:25 UTC by Kenji Hara
Modified: 2011-12-21 19:31 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2011-09-18 15:25:16 UTC
We cannot use std.exception.enforceEx in @safe function.

import std.exception;
void test1() @safe
{
    enforceEx!Exception(true, "");
    // Error: safe function 'test1' cannot call system function 'enforceEx'
}

This is dmd bug, using lazy parameter is inferred as unsafe, so whole enforceEx calling is inferred as unsafe.

More simple test case.

T useLazy(T)(lazy T val)
{
    return val;
}
void test2() @safe
{
    useLazy(0);
    // Error: safe function 'test2' cannot call system function 'useLazy'
}
Comment 3 Kenji Hara 2011-12-21 19:31:25 UTC
*** Issue 6328 has been marked as a duplicate of this issue. ***