digitalmars.D - Best error msg ever
- Daniel Kozak (4/4) Feb 09 2017 source/app.d(51,37): Error: function
- =?UTF-8?Q?S=c3=b6nke_Ludwig?= (6/10) Feb 09 2017 Must be caused by Path meaning two different type definitions. The most
- Daniel Kozak via Digitalmars-d (3/14) Feb 09 2017 Yes, btw it is impossible to build https://github.com/dlang/dub-registry...
- =?UTF-8?Q?S=c3=b6nke_Ludwig?= (2/18) Feb 10 2017 Thanks for the notice, I've committed a fix for DUB 1.2.1
- Era Scarecrow (12/19) Feb 09 2017 I'll have to agree. Back in ... 2009? I was in a company where
- Adam D. Ruppe (4/7) Feb 09 2017 They do have different full names, which includes the module name
- Era Scarecrow (4/8) Feb 09 2017 So maybe when the class name along can be ambiguous program it to
- Profile Anaysis (5/13) Feb 11 2017 The compiler actually has no brains, it's the people that program
- Era Scarecrow (5/8) Feb 09 2017 Oh right forgot to mention one important detail. In Java the
- Nemanja Boric (13/22) Feb 10 2017 I saw it happen with D as well: everything compiles, everything is
- Walter Bright (2/9) Feb 10 2017 That's why such casts are not allowed in @safe code.
- Chris Wright (4/14) Feb 10 2017 I'm a bit surprised by that. In @system code, you can cast, and it resul...
- Jack Stouffer (8/9) Feb 10 2017 Yes it does, for pointers anyway
- Walter Bright (5/19) Feb 10 2017 It depends on just what is being cast. If you're casting an interface to...
- Chris Wright (13/17) Feb 10 2017 Default-initialized variables, sorry.
- Walter Bright (2/10) Feb 11 2017 It's the other way around that's unsafe - casting an interface to an Obj...
- Kagamin (4/5) Feb 13 2017 Do you have an example? How it can be? Only classes can implement
- Daniel Kozak via Digitalmars-d (2/6) Feb 13 2017 Not all classes, extern(C++) classes does not
- Kagamin (3/4) Feb 13 2017 C++ only has C++ interfaces and they are different from D
- Daniel Kozak via Digitalmars-d (2/6) Feb 13 2017 and I guess even ComObject does not inherit from Object
- Kagamin (8/9) Feb 13 2017 This compiles:
- Mike Parker (4/13) Feb 13 2017 "References cannot be upcast to the enclosing class object, nor
- Kagamin (3/6) Feb 13 2017 COM interfaces can't be downcasted indeed, but it should be
- Chris Wright (7/15) Feb 13 2017 But the case that I brought up was cross-casting.
- Daniel Kozak via Digitalmars-d (4/8) Feb 09 2017 Problem is with multiple Path declaration, but with this error message
- Stefan Koch (2/11) Feb 09 2017 please do submit an request for this,
- Daniel Kozak via Digitalmars-d (3/15) Feb 09 2017 It would be probably duplicate of this one
source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?
Feb 09 2017
Am 09.02.2017 um 22:20 schrieb Daniel Kozak:source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Must be caused by Path meaning two different type definitions. The most likely cause is that by default the DUB sources use their own version of Path, while if vibe.d is available in the dependency graph, they will use the ones defined there instead. But the error message is indeed awful.
Feb 09 2017
Dne 9.2.2017 v 22:28 Sönke Ludwig via Digitalmars-d napsal(a):Am 09.02.2017 um 22:20 schrieb Daniel Kozak:Yes, btw it is impossible to build https://github.com/dlang/dub-registry right now because of thissource/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Must be caused by Path meaning two different type definitions. The most likely cause is that by default the DUB sources use their own version of Path, while if vibe.d is available in the dependency graph, they will use the ones defined there instead. But the error message is indeed awful.
Feb 09 2017
Am 09.02.2017 um 22:44 schrieb Daniel Kozak via Digitalmars-d:Dne 9.2.2017 v 22:28 Sönke Ludwig via Digitalmars-d napsal(a):Thanks for the notice, I've committed a fix for DUB 1.2.1Am 09.02.2017 um 22:20 schrieb Daniel Kozak:Yes, btw it is impossible to build https://github.com/dlang/dub-registry right now because of thissource/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Must be caused by Path meaning two different type definitions. The most likely cause is that by default the DUB sources use their own version of Path, while if vibe.d is available in the dependency graph, they will use the ones defined there instead. But the error message is indeed awful.
Feb 10 2017
On Thursday, 9 February 2017 at 21:28:58 UTC, Sönke Ludwig wrote:Am 09.02.2017 um 22:20 schrieb Daniel Kozak:I'll have to agree. Back in ... 2009? I was in a company where we were doing web development for a bit, and one curious error that came up was when trying to assign or work with the Date object. Seems the built in Date class wasn't the same as the Sql.Date that was being used (but had the same name). Apparently it took like 2 hours to figure out what was going on. In cases like these i really wish the structure of the class/struct had a hash or something (based on source or struct layout or something) to help differentiate it rather than just by name, and reverse lookup the exact file location(s) of where the struct in question comes from.source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Must be caused by Path meaning two different type definitions.
Feb 09 2017
On Friday, 10 February 2017 at 02:53:50 UTC, Era ScarecrowIn cases like these i really wish the structure of the class/struct had a hash or something (based on source or struct layout or something)They do have different full names, which includes the module name and uniquely differentiates them. The compiler knows it too, just isn't smart enough to actually display it in times like this.
Feb 09 2017
On Friday, 10 February 2017 at 03:07:28 UTC, Adam D. Ruppe wrote:They do have different full names, which includes the module name and uniquely differentiates them. The compiler knows it too, just isn't smart enough to actually display it in times like this.So maybe when the class name along can be ambiguous program it to give a full or non-ambiguous path for which class/structs they actually are? Seems like it would be a 1-2 line change...
Feb 09 2017
On Friday, 10 February 2017 at 03:07:28 UTC, Adam D. Ruppe wrote:On Friday, 10 February 2017 at 02:53:50 UTC, Era ScarecrowThe compiler actually has no brains, it's the people that program the compiler that you have to look at. Either they have no brains or are too lazy to care. After all, it's not their time that gets wasted.In cases like these i really wish the structure of the class/struct had a hash or something (based on source or struct layout or something)They do have different full names, which includes the module name and uniquely differentiates them. The compiler knows it too, just isn't smart enough to actually display it in times like this.
Feb 11 2017
On Friday, 10 February 2017 at 02:53:50 UTC, Era Scarecrow wrote:Seems the built in Date class wasn't the same as the Sql.Date that was being used (but had the same name). Apparently it took like 2 hours to figure out what was going on.Oh right forgot to mention one important detail. In Java the program compiled without errors; It was when it was trying to be used that it would crash unexpectedly. Refusing to compile is slightly better than crashing unexpectedly later.
Feb 09 2017
On Friday, 10 February 2017 at 04:02:17 UTC, Era Scarecrow wrote:On Friday, 10 February 2017 at 02:53:50 UTC, Era Scarecrow wrote:I saw it happen with D as well: everything compiles, everything is fine, and suddenly segfault. The issue was caused by template argument, two modules with the same name, but from different packages (think `myalib.blah.morebla.foo` and `myblib.blah.morebla.foo`) and a cast somewhere in the middle of the callstack which casted the first template argument to the second one, where the `myalib`'s foo was casted to `myblib`'s interface. Worse of all, `myalib` and `myblib` were just mentioned in the imports, far away from the call site.Seems the built in Date class wasn't the same as the Sql.Date that was being used (but had the same name). Apparently it took like 2 hours to figure out what was going on.Oh right forgot to mention one important detail. In Java the program compiled without errors; It was when it was trying to be used that it would crash unexpectedly. Refusing to compile is slightly better than crashing unexpectedly later.
Feb 10 2017
On 2/10/2017 4:41 AM, Nemanja Boric wrote:I saw it happen with D as well: everything compiles, everything is fine, and suddenly segfault. The issue was caused by template argument, two modules with the same name, but from different packages (think `myalib.blah.morebla.foo` and `myblib.blah.morebla.foo`) and a cast somewhere in the middle of the callstack which casted the first template argument to the second one, where the `myalib`'s foo was casted to `myblib`'s interface.That's why such casts are not allowed in safe code.
Feb 10 2017
On Fri, 10 Feb 2017 12:32:19 -0800, Walter Bright wrote:On 2/10/2017 4:41 AM, Nemanja Boric wrote:I'm a bit surprised by that. In system code, you can cast, and it results in a null pointer. A well-known value. Just like using an uninitialized variable. And safe doesn't stop you from using uninitialized variables.I saw it happen with D as well: everything compiles, everything is fine, and suddenly segfault. The issue was caused by template argument, two modules with the same name, but from different packages (think `myalib.blah.morebla.foo` and `myblib.blah.morebla.foo`) and a cast somewhere in the middle of the callstack which casted the first template argument to the second one, where the `myalib`'s foo was casted to `myblib`'s interface.That's why such casts are not allowed in safe code.
Feb 10 2017
On Saturday, 11 February 2017 at 01:14:03 UTC, Chris Wright wrote:And safe doesn't stop you from using uninitialized variables.Yes it does, for pointers anyway void main() safe { int[] a = void; } /d296/f663.d(3): Error: variable f663.main.a void initializers for pointers not allowed in safe functions
Feb 10 2017
On 2/10/2017 5:14 PM, Chris Wright wrote:On Fri, 10 Feb 2017 12:32:19 -0800, Walter Bright wrote:It depends on just what is being cast. If you're casting an interface to an Object, it is not allowed in safe code because not all interfaces are Objects, and this is not reliably detectable at runtime.On 2/10/2017 4:41 AM, Nemanja Boric wrote:I'm a bit surprised by that. In system code, you can cast, and it results in a null pointer. A well-known value.I saw it happen with D as well: everything compiles, everything is fine, and suddenly segfault. The issue was caused by template argument, two modules with the same name, but from different packages (think `myalib.blah.morebla.foo` and `myblib.blah.morebla.foo`) and a cast somewhere in the middle of the callstack which casted the first template argument to the second one, where the `myalib`'s foo was casted to `myblib`'s interface.That's why such casts are not allowed in safe code.And safe doesn't stop you from using uninitialized variables.As shown, it does.
Feb 10 2017
On Fri, 10 Feb 2017 21:19:37 -0800, Walter Bright wrote:On 2/10/2017 5:14 PM, Chris Wright wrote:Default-initialized variables, sorry. I don't see what's less safe about cast(MyInterface)new Object than cast(MyInterface)null The only difference is that there is a runtime call in between in the first example. And we'll get a similar runtime call with similar guarentees if it's instead cast(MyClass)new Object Except this version is accepted in safe code. It seems inconsistent, and I'm wondering what the reasoning behind it is. The error message doesn't offer a way to reach an explanation.And safe doesn't stop you from using uninitialized variables.As shown, it does.
Feb 10 2017
On 2/10/2017 9:42 PM, Chris Wright wrote:On Fri, 10 Feb 2017 21:19:37 -0800, Walter Bright wrote:It's the other way around that's unsafe - casting an interface to an Object.On 2/10/2017 5:14 PM, Chris Wright wrote:Default-initialized variables, sorry. I don't see what's less safe about cast(MyInterface)new ObjectAnd safe doesn't stop you from using uninitialized variables.As shown, it does.
Feb 11 2017
On Saturday, 11 February 2017 at 05:19:37 UTC, Walter Bright wrote:not all interfaces are ObjectsDo you have an example? How it can be? Only classes can implement interfaces, and classes inherit from Object.
Feb 13 2017
Dne 13.2.2017 v 14:12 Kagamin via Digitalmars-d napsal(a):On Saturday, 11 February 2017 at 05:19:37 UTC, Walter Bright wrote:Not all classes, extern(C++) classes does notnot all interfaces are ObjectsDo you have an example? How it can be? Only classes can implement interfaces, and classes inherit from Object.
Feb 13 2017
On Monday, 13 February 2017 at 13:18:33 UTC, Daniel Kozak wrote:Not all classes, extern(C++) classes does notC++ only has C++ interfaces and they are different from D interfaces.
Feb 13 2017
Dne 13.2.2017 v 14:12 Kagamin via Digitalmars-d napsal(a):On Saturday, 11 February 2017 at 05:19:37 UTC, Walter Bright wrote:and I guess even ComObject does not inherit from Objectnot all interfaces are ObjectsDo you have an example? How it can be? Only classes can implement interfaces, and classes inherit from Object.
Feb 13 2017
On Monday, 13 February 2017 at 13:21:44 UTC, Daniel Kozak wrote:and I guess even ComObject does not inherit from ObjectThis compiles: void f() { import core.sys.windows.com; ComObject a; Object b=a; }
Feb 13 2017
On Monday, 13 February 2017 at 13:38:23 UTC, Kagamin wrote:On Monday, 13 February 2017 at 13:21:44 UTC, Daniel Kozak wrote:"References cannot be upcast to the enclosing class object, nor can they be downcast to a derived interface." https://dlang.org/spec/interface.html#com-interfacesand I guess even ComObject does not inherit from ObjectThis compiles: void f() { import core.sys.windows.com; ComObject a; Object b=a; }
Feb 13 2017
On Monday, 13 February 2017 at 14:46:38 UTC, Mike Parker wrote:"References cannot be upcast to the enclosing class object, nor can they be downcast to a derived interface." https://dlang.org/spec/interface.html#com-interfacesCOM interfaces can't be downcasted indeed, but it should be possible for D interfaces.
Feb 13 2017
On Mon, 13 Feb 2017 15:09:31 +0000, Kagamin wrote:On Monday, 13 February 2017 at 14:46:38 UTC, Mike Parker wrote:But the case that I brought up was cross-casting. I have an object. It's a D object, which the compiler knows. I don't know if it implements a specific interface, so I cast it. That gives me an expression of the interface type that either refers to the same object or is null. Except it isn't safe for some unknown reason."References cannot be upcast to the enclosing class object, nor can they be downcast to a derived interface." https://dlang.org/spec/interface.html#com-interfacesCOM interfaces can't be downcasted indeed, but it should be possible for D interfaces.
Feb 13 2017
Dne 9.2.2017 v 22:20 Daniel Kozak via Digitalmars-d napsal(a):source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Problem is with multiple Path declaration, but with this error message it is really hard to find out which one. Maybe it would be better to show full names of symbol
Feb 09 2017
On Thursday, 9 February 2017 at 21:31:48 UTC, Daniel Kozak wrote:Dne 9.2.2017 v 22:20 Daniel Kozak via Digitalmars-d napsal(a):please do submit an request for this,source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Problem is with multiple Path declaration, but with this error message it is really hard to find out which one. Maybe it would be better to show full names of symbol
Feb 09 2017
Dne 9.2.2017 v 22:36 Stefan Koch via Digitalmars-d napsal(a):On Thursday, 9 February 2017 at 21:31:48 UTC, Daniel Kozak wrote:It would be probably duplicate of this one https://issues.dlang.org/show_bug.cgi?id=9631Dne 9.2.2017 v 22:20 Daniel Kozak via Digitalmars-d napsal(a):please do submit an request for this,source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile (Path file, bool silent_fail = false) is not callable using argument types (Path, bool) WTF?Problem is with multiple Path declaration, but with this error message it is really hard to find out which one. Maybe it would be better to show full names of symbol
Feb 09 2017