Issue 24848 - bad parser diagnostic for a partial MulExp
Summary: bad parser diagnostic for a partial MulExp
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: diagnostic, pull
Depends on:
Blocks:
 
Reported: 2024-11-08 04:59 UTC by basile-z
Modified: 2024-11-10 09:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description basile-z 2024-11-08 04:59:45 UTC
given the wrong code:

```
module runnable;

void main()
{
    struct A1 {}
    if (A1*) {}
    return;
}   
```

you get the error messages

> /tmp/temp_7FA97E5E13D0.d(6,12): Error: expression expected, not `)`>
> /tmp/temp_7FA97E5E13D0.d(6,14): Error: missing closing `)` after `if (A1 * 0`

The second message is very bad. First it does not output the input. In no way we multiply by zero. Second the closing right paren is there.
Comment 1 Dlang Bot 2024-11-08 12:51:13 UTC
@ntrel created dlang/dmd pull request #17055 "Fix Bugzilla 24848 - bad parser diagnostic for a partial MulExp" fixing this issue:

- Fix Bugzilla 24848 - bad parser diagnostic for a partial MulExp

https://github.com/dlang/dmd/pull/17055
Comment 2 Nick Treleaven 2024-11-08 12:53:49 UTC
> In no way we multiply by zero.

This happens for pretty much any binary expression, the pull fixes that. This is the main bug IMO.

> Second the closing right paren is there. 

I think there are many cases where subsequent parser error messages are confusing.
Comment 3 Dlang Bot 2024-11-10 09:21:21 UTC
dlang/dmd pull request #17055 "Fix Bugzilla 24848 - bad parser diagnostic for a partial MulExp" was merged into master:

- 5d01f144e2cc63a9c1c0edd5ab954a8edac11403 by Nick Treleaven:
  Fix Bugzilla 24848 - bad parser diagnostic for a partial MulExp

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