auto

language_fan foo at bar.com.invalid
Wed Aug 12 08:36:27 PDT 2009


Wed, 12 Aug 2009 15:19:10 +0000, language_fan himself wrote:

> Wed, 12 Aug 2009 10:22:22 -0400, Jarrett Billingsley thusly wrote:
> 
>> but DMD crashes.  :P
> 
> Who would have guessed! It would help if the compiler knew how to do
> semantic analysis.. here are a couple of additional test cases - a type
> checker for these can be written in approximately 30 minutes in Prolog
> or SML or something similar.
> 
> # auto foo() { return 1; }
> 
> # pragma(msg, typeof(foo).stringof);
> 
> # void main() {
> #   foo();
> # }
> 
> : foo.d(3): Error: forward reference to foo : foo.d(3): Error: forward
> reference to inferred return type of function call (())()
> : (())()
> 
> 
> # auto foo(int a) { return a>0 ? foo(a-1) : a; }
> 
> # void main() {
> #   foo(0);
> #}
> 
> : foo.d(1): Error: forward reference to foo : foo.d(1): Error: forward
> reference to inferred return type of function call foo(a - 1)

Another case

# void main() {
#   auto foo() { return; }
#   foo();
# }

: foo.d(2): no identifier for declarator foo
: foo.d(2): semicolon expected, not '{'



More information about the Digitalmars-d mailing list