Bug 6690 – Using lazy parameter should be inferred as @safe
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-09-18T15:25:00Z
Last change time
2011-12-21T19:31:25Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2011-09-18T15:25:16Z
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'
}