Issue 22283 - -preview=in -inline leads to strange error inside object.d
Summary: -preview=in -inline leads to strange error inside object.d
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 blocker
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-09-06 15:35 UTC by Temtaime
Modified: 2021-10-18 22:30 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Temtaime 2021-09-06 15:35:08 UTC
void main()
{
    try
    {
    }
    catch(Throwable e)
        e.toString;
}

compile with -preview=in -inline:

/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2405): Error: none of the overloads of `toString` are callable using argument types `(void)`, candidates are:
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2402):        `object.Throwable.toString()`
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2415):        `object.Throwable.toString(scope void delegate(in char[]) sink)`
Comment 1 Tejas_Garhewal 2021-09-07 05:47:57 UTC
(In reply to Temtaime from comment #0)
> void main()
> {
>     try
>     {
>     }
>     catch(Throwable e)
>         e.toString;
> }
> 
> compile with -preview=in -inline:
> 
> /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2405): Error: none
> of the overloads of `toString` are callable using argument types `(void)`,
> candidates are:
> /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2402):       
> `object.Throwable.toString()`
> /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2415):       
> `object.Throwable.toString(scope void delegate(in char[]) sink)`

Well, it's not working for me even when I remove preview=in

But my error messages are different(ldc 1.25.0 based on dmd 2.095.1):


Error: none of the overloads of this are callable using argument types (), candidates are:


/usr/lib/ldc/x86_64-redhat-linux-gnu/include/d/object.d(2140):        object.Exception.this(string msg, string file = __FILE__, ulong line = cast(ulong)__LINE__, Throwable nextInChain = null)


/usr/lib/ldc/x86_64-redhat-linux-gnu/include/d/object.d(2145):        object.Exception.this(string msg, Throwable nextInChain, string file = __FILE__, ulong line = cast(ulong)__LINE__)

(whitespace inserted by me)

Of course, providing a string argument to Exception solves this, preview=in or otherwise.
Comment 2 Tejas_Garhewal 2021-09-07 05:50:31 UTC
(In reply to Tejas_Garhewal from comment #1)
> (In reply to Temtaime from comment #0)
> > void main()
> > {
> >     try
> >     {
> >     }
> >     catch(Throwable e)
> >         e.toString;
> > }
> > 
> > compile with -preview=in -inline:
> > 
> > /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2405): Error: none
> > of the overloads of `toString` are callable using argument types `(void)`,
> > candidates are:
> > /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2402):       
> > `object.Throwable.toString()`
> > /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2415):       
> > `object.Throwable.toString(scope void delegate(in char[]) sink)`
> 
> Well, it's not working for me even when I remove preview=in
> 

Oh, and -inline makes no difference for me.
Comment 3 Temtaime 2021-09-07 05:53:26 UTC
You can try it on
https://run.dlang.io/is/w2P2tQ
It makes difference, maybe your compiler is outdated / etc
Comment 4 Tejas_Garhewal 2021-09-07 06:09:58 UTC
(In reply to Temtaime from comment #3)
> You can try it on
> https://run.dlang.io/is/w2P2tQ
> It makes difference, maybe your compiler is outdated / etc

Yeah that error is coming for me on dmd 2.097.1

Maybe regression?
Comment 5 Tejas_Garhewal 2021-09-07 06:11:43 UTC
(In reply to Tejas_Garhewal from comment #4)
> (In reply to Temtaime from comment #3)
> > You can try it on
> > https://run.dlang.io/is/w2P2tQ
> > It makes difference, maybe your compiler is outdated / etc
> 
> Yeah that error is coming for me on dmd 2.097.1
> 
> Maybe regression?

Sorry, 2.079.2
Comment 6 Dlang Bot 2021-10-18 09:44:20 UTC
@Geod24 created dlang/druntime pull request #3592 "[stable] Fix 22283: Weird error in object with inline and preview=in" fixing this issue:

- Fix 22283: Weird error in object with inline and preview=in
  
  This happens because preview=in uses a 'stronger' version of 'in',
  which makes 'scope const' and 'in' parameters not covariant.
  Why it triggers with '-inline' and not without is anyone's guess.

https://github.com/dlang/druntime/pull/3592
Comment 7 Dlang Bot 2021-10-18 22:30:16 UTC
dlang/druntime pull request #3592 "[stable] Fix 22283: Weird error in object with inline and preview=in" was merged into master:

- 096fa3656feece08d2fce6cd018f6bdacf83c175 by Geod24:
  Fix 22283: Weird error in object with inline and preview=in
  
  This happens because preview=in uses a 'stronger' version of 'in',
  which makes 'scope const' and 'in' parameters not covariant.
  Why it triggers with '-inline' and not without is anyone's guess.

https://github.com/dlang/druntime/pull/3592