Bug 19066 – [REG 2.080.1] Error: `const(Object)` is used as a type with structs that have symbol named Object

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-07-06T12:07:13Z
Last change time
2018-07-11T05:22:53Z
Keywords
pull, rejects-valid
Assigned to
Steven Schveighoffer
Creator
Jacob Carlborg

Comments

Comment #0 by doob — 2018-07-06T12:07:13Z
The following code worked fine using DMD 2.080.0 but fails with 2.081.0 and up to master (ed6386ada4549d70797c3d09e51e05756de174d4). class Foo {} struct Bar { Foo Object; } Compiling this with 2.081.0 will give the following error message: Error: `const(Object)` is used as a type It does not include any location information which made this more difficult to find a reduced test case for.
Comment #1 by schveiguy — 2018-07-06T14:17:38Z
Jacob, I know what this is! It's the fix we worked on at dconf. https://github.com/dlang/dmd/pull/8222 What's happening here is the local name Object is overriding the global type Object, so the generated toHash function uses that instead. I'll try using the fully qualified type, and see if it fixes the issue.
Comment #2 by schveiguy — 2018-07-06T15:10:45Z
Updating regression to reflect where the error actually was introduced.
Comment #3 by doob — 2018-07-06T15:15:04Z
(In reply to Steven Schveighoffer from comment #1) > I'll try using the fully qualified type, and see if it fixes the issue. I gave that a try, it resulted in a new error message: Error: need `this` for `Object` of type `main.Foo` Might be a different issue.
Comment #4 by schveiguy — 2018-07-06T15:17:34Z
Comment #5 by schveiguy — 2018-07-06T15:19:03Z
(In reply to Jacob Carlborg from comment #3) > I gave that a try, it resulted in a new error message: Not sure what you tried, but I found something that seems to work, at least locally.
Comment #6 by schveiguy — 2018-07-06T15:19:52Z
Oh, haha! I meant I'll try updating the compiler to use the fully qualified name object.Object :)
Comment #7 by doob — 2018-07-06T17:52:39Z
(In reply to Steven Schveighoffer from comment #6) > Oh, haha! I meant I'll try updating the compiler to use the fully qualified > name object.Object :) Yes, I did that. But now looking at your PR I see that I only updated to use the fully qualified name in the static if, not later in the body. Your fix works for me.
Comment #8 by github-bugzilla — 2018-07-11T05:22:52Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/2ff1ac05b6d523814018dec5970be117c08ff8dd Fix issue 19066 - Allow using symobls Object and object inside a struct without a toHash override. https://github.com/dlang/dmd/commit/9b7ac1de8071934235707cf9faf2e45ca6be3c23 Merge pull request #8463 from schveiguy/fix19066 Fix issue 19066 - Allow using symobls Object inside a struct without a toHash override