Bug 24632 – Fully qualified package name in package requires import?

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-06-26T16:09:23Z
Last change time
2024-12-13T19:36:02Z
Assigned to
No Owner
Creator
zxinsworld
Moved to GitHub: dmd#20476 →

Comments

Comment #0 by zxinsworld — 2024-06-26T16:09:23Z
When using the fully qualified name of a package inside that package you will receive either a deprecation message or an error, depending on how you referenced the fully qualified package name. To reproduce, first create a file called 'package.d'. This behaviour is ONLY present if the file name is 'package.d', so in other words this issue only applies to packages, not to regular modules. To get the deprecation message, paste this into package.d: ```d module bug.buggier; void main(){ alias thisModule = bug.buggier; } ``` To get an error, paste this into package.d: ```d module bug.buggier; void fn(){} void main(){ bug.buggier.fn(); } ``` Now compile. Expected result: it should work, just like how it works in any other module. Actual result: The compiler insists that you add `static import bug.buggier;`. Adding the static import makes everything compile* without any warnings, but why should you have to import a package into itself just for it to reference its own contents? If you don't use fully qualified names then the package's contents are freely available to itself. * Unless you use LDC2 & add the static import the 'to get an error' example, in which case LDC2 will crash hilariously. Tested with: - macOS 14.5 on aarch64 using LDC2 1.38.0 (based on DMD v2.108.1) - Debian on amd64 using DMD v2.106.1
Comment #1 by robert.schadek — 2024-12-13T19:36:02Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20476 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB