Jump to page: 1 2
Thread overview
[Issue 19873] unittest should be by default @system even with -preview=dip1000
May 14, 2019
Jacob Carlborg
May 14, 2019
Seb
May 15, 2019
Jacob Carlborg
Mar 12, 2020
Walter Bright
Mar 12, 2020
Walter Bright
[Issue 19873] function should be by default @system even with -preview=dip1000
Mar 12, 2020
Walter Bright
Mar 12, 2020
Walter Bright
Mar 12, 2020
Walter Bright
Mar 12, 2020
Mathias LANG
Jul 06, 2021
Dlang Bot
Nov 16, 2021
Dlang Bot
May 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19873

Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob@me.com

--- Comment #1 from Jacob Carlborg <doob@me.com> ---
Would it be a good idea to infer attributes for unittest?

--
May 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19873

--- Comment #2 from Seb <greeenify@gmail.com> ---
I think this is what's (wrongly?) happening here which is probably why the unittest without @system results in an error.

--
May 15, 2019
https://issues.dlang.org/show_bug.cgi?id=19873

--- Comment #3 from Jacob Carlborg <doob@me.com> ---
(In reply to Seb from comment #2)
> I think this is what's (wrongly?) happening here which is probably why the unittest without @system results in an error.

Then it sounds like the inference is broken.

--
March 12, 2020
https://issues.dlang.org/show_bug.cgi?id=19873

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
unittest has nothing to do with the issue. Calling it `void test()` instead
does the same thing.

--
March 12, 2020
https://issues.dlang.org/show_bug.cgi?id=19873

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
Here's what's happening:

------- reduced test case ----------
void test() {
    int i;
    int* p = &i; // <= `scope` is inferred for `p`
    int*[]  slicep = [p];
}
----------------------

If it is declared:

    scope int*p = &i;

the error will occur regardless of the application of @system. Looking at the code in escape.d checkAssignEscape():

------------
// Try to infer 'scope' for va if in a function not marked @system
bool inferScope = false;
if (va && sc.func && sc.func.type && sc.func.type.ty == Tfunction)
    inferScope = (cast(TypeFunction)sc.func.type).trust != TRUST.system;
------------
https://github.com/dlang/dmd/blob/master/src/dmd/escape.d#L578

and there it is. It is deliberate. What's going on is there are actually 4 trust levels - system, trusted, safe, and default_. The fourth state default_ is necessary for functions that will have their attributes inferred. I went a little further here to assume a bit more @safety in default_ functions unless the user specifically marked it as @system.

As you know, I'd like to see @safe as the default. While this issue is a bug, it's in the direction we need to go anyway so it shouldn't be "fixed".

--
March 12, 2020
https://issues.dlang.org/show_bug.cgi?id=19873

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|unittest should be by       |function should be by
                   |default @system even with   |default @system even with
                   |-preview=dip1000            |-preview=dip1000

--
March 12, 2020
https://issues.dlang.org/show_bug.cgi?id=19873

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe

--
March 12, 2020
https://issues.dlang.org/show_bug.cgi?id=19873

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/10898

--
March 12, 2020
https://issues.dlang.org/show_bug.cgi?id=19873

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |pro.mathias.lang@gmail.com
         Resolution|WONTFIX                     |---
           Severity|enhancement                 |normal

--- Comment #7 from Mathias LANG <pro.mathias.lang@gmail.com> ---
> As you know, I'd like to see @safe as the default. While this issue is a bug, it's in the direction we need to go anyway so it shouldn't be "fixed".

What ? It *is* a bug. By the current definition of the language, an error that shouldn't be triggered in `@system` code is triggered in `@system` code.

`@safe` by default is orthogonal and should be handled on its own. Breaking the language because "we're going to do it" is not reasonable, especially when this DIP hasn't been accepted and is so far into the future.

--
July 06, 2021
https://issues.dlang.org/show_bug.cgi?id=19873

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #12821 "Fix issue 19873 - function should be by default @system even with -preview=dip1000" fixing this issue:

- fix issue 19873 - function should be by default @system even with -preview=dip1000

https://github.com/dlang/dmd/pull/12821

--
« First   ‹ Prev
1 2