www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D1: accepts-invalid?

reply klickverbot <see klickverbot.at> writes:
Hello all,

currently, DMD accepts the following code, but the resulting binary 
bus-errors at runtime:

---
import std.stdio;

void foo( string str ) () {
     writefln( str );
}

void bar( string text ) {
     foo!( text );
}

void main() {	
     bar( "asdf" );
}
---

Shouldn't this be a compile-time error?

Thanks,
klickverbot
Aug 23 2010
next sibling parent Don <nospam nospam.com> writes:
klickverbot wrote:
 Hello all,
 
 currently, DMD accepts the following code, but the resulting binary 
 bus-errors at runtime:
 
 ---
 import std.stdio;
 
 void foo( string str ) () {
     writefln( str );
 }
 
 void bar( string text ) {
     foo!( text );
 }
 
 void main() {   
     bar( "asdf" );
 }
 ---
 
 Shouldn't this be a compile-time error?
 
 Thanks,
 klickverbot
 
Yes. Please put it in Bugzilla.
Aug 23 2010
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"klickverbot" <see klickverbot.at> wrote in message 
news:i4ualh$1qh1$1 digitalmars.com...
 Hello all,

 currently, DMD accepts the following code, but the resulting binary 
 bus-errors at runtime:

 ---
 import std.stdio;

 void foo( string str ) () {
     writefln( str );
 }

 void bar( string text ) {
     foo!( text );
 }

 void main() { bar( "asdf" );
 }
 ---

 Shouldn't this be a compile-time error?
I'm pretty sure that should work fine in D1 without any errors. Although on 1.062 I'm getting this (at run-time): --------------------------------------- Error: 4invalid UTF-8 sequence 1 --------------------------------------- Which is rather weird. It does work on 2.048, although it shouldn't since there's no "()" after "foo!(text)" (I guess that just hasn't been implemented yet).
Aug 23 2010
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 23 Aug 2010 15:29:32 -0400, Nick Sabalausky <a a.a> wrote:

 "klickverbot" <see klickverbot.at> wrote in message
 news:i4ualh$1qh1$1 digitalmars.com...
 Hello all,

 currently, DMD accepts the following code, but the resulting binary
 bus-errors at runtime:

 ---
 import std.stdio;

 void foo( string str ) () {
     writefln( str );
 }

 void bar( string text ) {
     foo!( text );
 }

 void main() { bar( "asdf" );
 }
 ---

 Shouldn't this be a compile-time error?
I'm pretty sure that should work fine in D1 without any errors. Although on 1.062 I'm getting this (at run-time): --------------------------------------- Error: 4invalid UTF-8 sequence 1 ---------------------------------------
Wait, how can you pass a runtime string as a template parameter? I'm pretty sure the whole thing is a bug. -Steve
Aug 23 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message 
news:op.vhwolemleav7ka localhost.localdomain...
 On Mon, 23 Aug 2010 15:29:32 -0400, Nick Sabalausky <a a.a> wrote:

 "klickverbot" <see klickverbot.at> wrote in message
 news:i4ualh$1qh1$1 digitalmars.com...
 Hello all,

 currently, DMD accepts the following code, but the resulting binary
 bus-errors at runtime:

 ---
 import std.stdio;

 void foo( string str ) () {
     writefln( str );
 }

 void bar( string text ) {
     foo!( text );
 }

 void main() { bar( "asdf" );
 }
 ---

 Shouldn't this be a compile-time error?
I'm pretty sure that should work fine in D1 without any errors. Although on 1.062 I'm getting this (at run-time): --------------------------------------- Error: 4invalid UTF-8 sequence 1 ---------------------------------------
Wait, how can you pass a runtime string as a template parameter? I'm pretty sure the whole thing is a bug.
Oh, yea, now I see it :)
Aug 23 2010
parent reply Don <nospam nospam.com> writes:
Nick Sabalausky wrote:
 "Steven Schveighoffer" <schveiguy yahoo.com> wrote in message 
 news:op.vhwolemleav7ka localhost.localdomain...
 On Mon, 23 Aug 2010 15:29:32 -0400, Nick Sabalausky <a a.a> wrote:

 "klickverbot" <see klickverbot.at> wrote in message
 news:i4ualh$1qh1$1 digitalmars.com...
 Hello all,

 currently, DMD accepts the following code, but the resulting binary
 bus-errors at runtime:

 ---
 import std.stdio;

 void foo( string str ) () {
     writefln( str );
 }

 void bar( string text ) {
     foo!( text );
 }

 void main() { bar( "asdf" );
 }
 ---

 Shouldn't this be a compile-time error?
I'm pretty sure that should work fine in D1 without any errors. Although on 1.062 I'm getting this (at run-time): --------------------------------------- Error: 4invalid UTF-8 sequence 1 ---------------------------------------
Wait, how can you pass a runtime string as a template parameter? I'm pretty sure the whole thing is a bug.
Oh, yea, now I see it :)
It may be a duplicate of bug 2962.
Aug 23 2010
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
On 24/08/2010 07:55, Don wrote:
 Nick Sabalausky wrote:
 "Steven Schveighoffer" <schveiguy yahoo.com> wrote in message
 news:op.vhwolemleav7ka localhost.localdomain...
<snip>
 Wait, how can you pass a runtime string as a template parameter? I'm
 pretty sure the whole thing is a bug.
Oh, yea, now I see it :)
It may be a duplicate of bug 2962.
Bug 2962 relies on an alias template parameter. It took me a moment or 3 to make out why you'd decided it isn't accepts-invalid. On the other hand, this clearly is. Stewart.
Sep 04 2010