Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
April 14, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 brian-schott@cox.net changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid, spec Blocks| |10233 -- |
April 15, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> --- (In reply to brian-schott from comment #0) > void function() foo = {}; > > According to the grammar spec, the latter should be parsed as a variable declaration whose type is "void function()", with a name of "foo" and an empty struct initializer. (By the way, the grammar does not allow empty struct initializers). This should not pass semantic analysis because a struct literal is not of type void function(). StructInitializer is defined as follows: StructInitializer: { StructMemberInitializers_opt } Between braces StructMemberInitializers is optional, so {} is properly accepted. And, If a delegate variable is initialized by empty StructInitializer, it is treated as a function literal in semantic phase. https://github.com/D-Programming-Language/dmd/blob/d4f778f96a85de9605a035864d3480e40097df28/src/init.c#L287 -- |
April 15, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 brian-schott@cox.net changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- --- Comment #2 from brian-schott@cox.net --- The compiler still rejects this: void function() bar { writeln("test"); } The grammar specification says this is valid. It does not require the '=' token. If the compiler's behavior is correct, the specification needs to be changed. Please do not close bugs while the specification is not consistent with the compiler just because the compiler's behavior is correct. -- |
April 15, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 --- Comment #3 from brian-schott@cox.net --- The grammar also states that function literals can have contracts by using the FunctionBody rule, but the compiler rejects this: void function() f = in { assert(true); } body { writeln("hello world"); } -- |
April 16, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 --- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> --- (In reply to brian-schott from comment #2) > The compiler still rejects this: > > void function() bar { writeln("test"); } > > The grammar specification says this is valid. It does not require the '=' token. If the compiler's behavior is correct, the specification needs to be changed. Even if grammar accept the token list, it could be rejected in some reason. In this case, it cannot be treated as a function definition, because of the lack of parameter list. More simple case is: auto auto x = 1; This is allowed in grammar, but will be rejected with the error "redundant storage class 'auto'". -- |
September 23, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> --- OK, the definition of more strict grammar for function declarations was not so difficult. https://github.com/D-Programming-Language/dlang.org/pull/660 -- |
September 24, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 github-bugzilla@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |FIXED -- |
September 24, 2014 [Issue 12579] DMD rejects valid function literal | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12579 --- Comment #6 from github-bugzilla@puremagic.com --- Commit pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/7fbb9cac0718f36e27c19905ec037f9bf692e774 fix Issue 12579 - DMD rejects valid function literal Remove FuncDeclaratorSuffixes to disallow zero, two or more parameter lists And disallow mixing C-style suffix in function declaration, as follows: void foo[](int a); -- |
Copyright © 1999-2021 by the D Language Foundation