Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types, types2: errors for absolute import path don't match (old) compiler, and are inconsistent with the compiler #43109

Closed
griesemer opened this issue Dec 10, 2020 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

For

package main
import "/foo"

the compiler reports:

main.go:2:8: import path cannot be absolute path

Both go/types and types2 report:

main.go:2:8: could not import /foo (can't find import: "/foo")
main.go:2:8: "/foo" imported and not used

Generally, should review all import path errors.

cc: @findleyr

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 10, 2020
@griesemer griesemer added this to the Go1.17 milestone Dec 10, 2020
@griesemer griesemer modified the milestones: Go1.17, Go1.18 Apr 28, 2021
@odeke-em
Copy link
Member

odeke-em commented Jan 8, 2022

Thank you for filing this issue @griesemer and Happy New Year to you and @findleyr!

I am currently at 90860e0 and it seems fixed; the result of this compilation using types2 seems to produce the desired result like this

go version devel go1.18-90860e0c31 Sat Jan 8 00:24:25 2022 +0000 darwin/amd64
package main
import "/foo"
main.go:2:8: could not import /foo (import path cannot be absolute path)
main.go:2:8: imported and not used: "/foo"

Shall we perhaps close this issue?

@griesemer
Copy link
Contributor Author

griesemer commented Jan 8, 2022

We're getting the correct could not import error with the compiler, but we shouldn't get an imported and not used error (after all it couldn't be imported in the first place). This still needs to be addressed but it's not crucial for 1.18. Moving to 1.19.

Also, `types2) (stand-alone) reports:

    check_test.go:159: testdata/manual.go2:10:8: could not import /foo (can't find import: "/foo")
    check_test.go:159: testdata/manual.go2:10:8: "/foo" imported but not used

@griesemer griesemer modified the milestones: Go1.18, Go1.19 Jan 8, 2022
@griesemer griesemer changed the title go/types, types2: "import path cannot be absolute path" error not reported go/types, types2: errors for absolute import path don't match (old) compiler, and are inconsistent with the compiler Jan 8, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/396875 mentions this issue: go/types, types2: no "imported but not used" error for unimported packages

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants