Skip to content

Commit

Permalink
[dev.unified] test: relax issue7921.go diagnostic message
Browse files Browse the repository at this point in the history
For constants literal, iimport/iexport read/write them as basic literal
nodes. So they are printed in diagnostic message as Go syntax. So "foo"
will be reported as string("foo").

Unified IR read/write the raw expression as string value, and when
printed in diagnostic, the string value is written out exactly as-is, so
"foo" will be written as "foo".

Thus, this CL relax the test in issue7921.go to match the string value only.

Updates #53058

Change-Id: I6fcf4fdcfc4b3be91cb53b081c48bd57186d8f35
Reviewed-on: https://go-review.googlesource.com/c/go/+/410795
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
  • Loading branch information
cuonglm committed Jun 9, 2022
1 parent c50c6bb commit 1a6c96b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
4 changes: 0 additions & 4 deletions src/cmd/compile/internal/noder/helpers.go
Expand Up @@ -39,10 +39,6 @@ func typed(typ *types.Type, n ir.Node) ir.Node {

// Values

func Const(pos src.XPos, typ *types.Type, val constant.Value) ir.Node {
return typed(typ, ir.NewBasicLit(pos, val))
}

func OrigConst(pos src.XPos, typ *types.Type, val constant.Value, op ir.Op, raw string) ir.Node {
orig := ir.NewRawOrigExpr(pos, op, raw)
return ir.NewConstExpr(val, typed(typ, orig))
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/issue7921.go
Expand Up @@ -41,7 +41,7 @@ func bufferNoEscape3(xs []string) string { // ERROR "xs does not escape$"

func bufferNoEscape4() []byte {
var b bytes.Buffer
b.Grow(64) // ERROR "bufferNoEscape4 ignoring self-assignment in bytes.b.buf = bytes.b.buf\[:bytes.m\]$" "inlining call to bytes.\(\*Buffer\).Grow$" "string\(.*\) escapes to heap"
b.Grow(64) // ERROR "bufferNoEscape4 ignoring self-assignment in bytes.b.buf = bytes.b.buf\[:bytes.m\]$" "inlining call to bytes.\(\*Buffer\).Grow$" `".+" escapes to heap`
useBuffer(&b)
return b.Bytes() // ERROR "inlining call to bytes.\(\*Buffer\).Bytes$"
}
Expand Down
1 change: 0 additions & 1 deletion test/run.go
Expand Up @@ -1997,7 +1997,6 @@ var unifiedFailures = setOf(
"escape4.go", // unified IR can inline f5 and f6; test doesn't expect this
"inline.go", // unified IR reports function literal diagnostics on different lines than -d=inlfuncswithclosures

"fixedbugs/issue7921.go", // prints "… escapes to heap", but test expects "string(…) escapes to heap"
"typeparam/issue47631.go", // unified IR can handle local type declarations
)

Expand Down

0 comments on commit 1a6c96b

Please sign in to comment.