digitalmars.D.bugs - [Issue 17136] New: dictionary get(value, defaultValue) should be
- via Digitalmars-d-bugs (36/36) Feb 01 2017 https://issues.dlang.org/show_bug.cgi?id=17136
https://issues.dlang.org/show_bug.cgi?id=17136 Issue ID: 17136 Summary: dictionary get(value, defaultValue) should be nothrow Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: greeenify gmail.com Consider this simple program: void main(string[] args) nothrow { int[string] dict; dict["a"] = 1; auto ret = dict.get("a", 0); } it yields the following: bar.d(6): Error: function 'object.get!(string, int).get' is not nothrow bar.d(2): Error: nothrow function 'D main' may throw Failed: ["dmd", "-v", "-c", "-of/tmp/.rdmd-1000/rdmd-bar.d-A4BDC7C9DEEC63B3D5E970F3DA9C439E/objs/bar.o", "bar.d", "-I."] However the following does compile: void main(string[] args) nothrow { int[string] dict; dict["a"] = 1; int ret = 0; if (auto val = "a" in dict) ret = *val; } --
Feb 01 2017