File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -823,6 +823,8 @@ MATCH implicitConvTo(Expression e, Type t)
823823 break ;
824824 }
825825 }
826+ else if (tn.ty == tyn)
827+ return m; // e.g. "foo"w -> const(wchar)*
826828 break ;
827829
828830 default :
Original file line number Diff line number Diff line change @@ -474,6 +474,19 @@ void test15778()
474474 static assert (! __traits(compiles, (ds[] = " a" w)));
475475}
476476
477+ /* **********************************/
478+ // https://github.com/dlang/dmd/issues/18342
479+ const (char )* cptr = " tic" c;
480+ const (wchar )* wcptr = " tac" w;
481+ immutable (dchar )* dcptr = " toe" d;
482+
483+ void test18342 ()
484+ {
485+ assert ( cptr[0 .. 4 ] == " tic\0 " c);
486+ assert (wcptr[0 .. 4 ] == " tac\0 " w);
487+ assert (dcptr[0 .. 4 ] == " toe\0 " d);
488+ }
489+
477490/* **********************************/
478491
479492void main ()
@@ -490,6 +503,7 @@ void main()
490503 testDIP29_5();
491504 testDIP29_6();
492505 test15778();
506+ test18342();
493507
494508 printf(" Success\n " );
495509}
You can’t perform that action at this time.
0 commit comments