You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: failure to reject unused dot import #22072
@mdempsky am sure you already know but the same applies when we import pretty much any package and have the same symbol matched and used in a struct e.g
@odeke-em Yep. The problem is that when we're noding the Buffer: 0 composite literal element, we don't have enough information to know whether it's a struct literal (which means Buffer is just a raw symbol) or an array/slice/map literal (where Buffer can be a named object, like a const or variable). Currently, we parse it as a named object, and then later take just the name if we realize it's a struct literal.
The problem with this approach is when we access the named object that's been dot imported, we eagerly mark the import as used, even if it turns out later we didn't need the object.
Activity
odeke-em commentedon Sep 28, 2017
@mdempsky am sure you already know but the same applies when we import pretty much any package and have the same symbol matched and used in a struct e.g
mdempsky commentedon Sep 28, 2017
@odeke-em Yep. The problem is that when we're noding the
Buffer: 0composite literal element, we don't have enough information to know whether it's a struct literal (which meansBufferis just a raw symbol) or an array/slice/map literal (whereBuffercan be a named object, like a const or variable). Currently, we parse it as a named object, and then later take just the name if we realize it's a struct literal.The problem with this approach is when we access the named object that's been dot imported, we eagerly mark the import as used, even if it turns out later we didn't need the object.
odeke-em commentedon Dec 23, 2017
@mdempsky aha, turns out that @griesemer had already reported this bug back in September 2013 with #6428. How should we handle the dups?
griesemer commentedon Dec 24, 2017
Duplicate of #6428.