[Issue 24301] [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24301

Dlang Bot  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Dlang Bot  ---
dlang/dmd pull request #15953 "Fix 24301 - Misleading error message when
passing non-copyable struct…" was merged into master:

- 1f8dc2b365e41d3fdfc20a6be5b439e92c97f3b5 by Paul Backus:
  Fix 24301 - Misleading error message when passing non-copyable struct by
value in @safe code

  If a copy constructor is explicitly marked with @disable, the error
  message should mention that, regardless of whether its attributes are
  allowed in the calling scope.

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

--


[Issue 24301] [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24301

Dlang Bot  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #2 from Dlang Bot  ---
@pbackus created dlang/dmd pull request #15953 "Fix 24301 - Misleading error
message when passing non-copyable struct…" fixing this issue:

- Fix 24301 - Misleading error message when passing non-copyable struct by
value in @safe code

  If a copy constructor is explicitly marked with @disable, the error
  message should mention that, regardless of whether its attributes are
  allowed in the calling scope.

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

--


[Issue 24301] [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24301

--- Comment #1 from Paul Backus  ---
Introduced in this PR:

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

--


[Issue 24301] [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24301

Paul Backus  changed:

   What|Removed |Added

   Keywords||diagnostic

--


[Issue 24301] New: [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24301

  Issue ID: 24301
   Summary: [REG 2.100] Misleading error message when passing
non-copyable struct by value in @safe code
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: snarwin+bugzi...@gmail.com

As of DMD 2.106.0, when attempting to compile the following program:

---
struct S
{
@disable this(ref S);
}

@safe void fun(S) {}

@safe void main()
{
S s;
fun(s);
}
---

...the following error message is produced:

---
bug.d(11): Error: function `bug.fun(S __param_0)` is not callable using
argument types `(S)`
bug.d(11):`ref S(ref S)` copy constructor cannot be called from a
`@safe` context
---

This message is misleading. The reason the copy constructor cannot be called is
that it is marked with @disable, and has nothing to do with @safe.

According to run.dlang.io, this misleading message was introduced between DMD
2.099.1 
and 2.100.2:

2.086.1 to 2.099.1: Failure with output:
-
onlineapp.d(11): Error: function `onlineapp.fun(S _param_0)` is not callable
using argument types `(S)`
onlineapp.d(11):`struct S` does not define a copy constructor for `S`
to `S` copies
-

2.100.2 to 2.103.1: Failure with output:
-
onlineapp.d(11): Error: function `onlineapp.fun(S _param_0)` is not callable
using argument types `(S)`
onlineapp.d(11):`ref S(ref S)` copy constructor cannot be called from a
`@safe` context
-

--


[Issue 24300] error message for a jump over `scope(exit)` leaks internal details

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24300

--- Comment #1 from Basile-z  ---
Not that much better... I meant

> Error: `goto` skips over `exit` scope guard

--


[Issue 24300] New: error message for a jump over `scope(exit)` leaks internal details

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24300

  Issue ID: 24300
   Summary: error message for a jump over `scope(exit)` leaks
internal details
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Keywords: diagnostic
  Severity: minor
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: b2.t...@gmx.com

The error output for

```d
extern(C) int puts(const char*);

int main () {
  goto L0;
  scope(exit) puts("meow");

  L0:
  puts("cat says");

  return 0;
}  
```

is 

> Error: cannot `goto` into `try` block

This leaks the fact that the exit scope guard is lowered to a try-finally
statement,
a detail that does not necessarily interests the user or that can even be
confusing

A better message would be

> Error: cannot `goto` skip over `exit` scope guard

--


[Issue 24291] ImportC: cannot compile janet.c

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24291

--- Comment #3 from anonymous4  ---
clang provides __has_extension function for such checks, but doesn't document
computed gotos.

--


[Issue 24291] ImportC: cannot compile janet.c

2023-12-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=24291

anonymous4  changed:

   What|Removed |Added

URL||https://forum.dlang.org/pos
   ||t/woaixickqgqvfsazutex@foru
   ||m.dlang.org

--- Comment #2 from anonymous4  ---
>From forum discussion:
---
One Problem with Janet is that it uses computed gotos which is a 
gcc extension
The code it complains about looks like:
```C
 /* opcode -> label lookup if using clang/GCC */
#ifdef JANET_USE_COMPUTED_GOTOS
 static void *op_lookup[255] = {
 &_JOP_NOOP,
 &_JOP_ERROR,
```

As you can see & is not valid C11.
Which is what the import C parser complains about.
---

Maybe something can be done there with that JANET_USE_COMPUTED_GOTOS define.

--