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

x/tools/go/ssa: make opaqueType less annoying to use #19670

Open
dominikh opened this issue Mar 23, 2017 · 1 comment
Open

x/tools/go/ssa: make opaqueType less annoying to use #19670

dominikh opened this issue Mar 23, 2017 · 1 comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dominikh
Copy link
Member

The ssa package defines an opaqueType, which is an "opaque and degenerate" type, currently used by the Range instruction. It truly is degenerate, embedding a nil types.Type, causing a call to types.Type.Underlying to panic.

Code that wants to operate on the types of instructions needs to specifically check for the Range instruction and skip it. There doesn't seem to be a way to check for this degenerate type specifically, which would at least permit passing types around without having to keep track of the originating instruction.

The simplest solution that I can think of is to implement Underlying as the identity function. However I suspect that this hasn't been done for a good reason?

/cc @alandonovan

@dominikh dominikh added this to the Unreleased milestone Mar 23, 2017
quasilyte added a commit to quasilyte/go-contributing-ru that referenced this issue Apr 1, 2018
New tasks include:
golang/go#19675 cmd/vet: report uses of -0 in float32/64 context
golang/go#19683 cmd/compile: eliminate usages of global lineno
golang/go#19670 x/tools/go/ssa: make opaqueType less annoying to use
golang/go#19636 encoding/base64: decoding is slow
golang/go#23471 x/perf/cmd/benchstat: tips or quickstart for newcomers
golang/go#19577 test: errorcheck support for intraline errors
golang/go#19490 cmd/vet: reduce the amount of false positives for -shadow mode
golang/go#19042 cmd/internal/obj: optimize wrapper method prologue for branch prediction
golang/go#19013 cmd/compile: add tool for understanding/debugging SSA rules
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@adonovan
Copy link
Member

(Better late than never)

The simplest solution that I can think of is to implement Underlying as the identity function. However I suspect that this hasn't been done for a good reason?

The reason I used this annoying type was to help point out (by making the program explode) places where a client assumes that ssa.Range has a legal Go type. In hindsight it would have been better to use an inaccurate but valid type such as (), instead of creating a minefield.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants