rewrite4.golden 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //gofmt -r=(x)->x
  2. // Copyright 2012 The Go Authors. All rights reserved.
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file.
  5. // Rewriting of parenthesized expressions (x) -> x
  6. // must not drop parentheses if that would lead to
  7. // wrong association of the operands.
  8. // Was issue 1847.
  9. package main
  10. // From example 1 of issue 1847.
  11. func _() {
  12. var t = (&T{1000}).Id()
  13. }
  14. // From example 2 of issue 1847.
  15. func _() {
  16. fmt.Println((*xpp).a)
  17. }
  18. // Some more test cases.
  19. func _() {
  20. _ = (-x).f
  21. _ = (*x).f
  22. _ = (&x).f
  23. _ = (!x).f
  24. _ = -x.f
  25. _ = *x.f
  26. _ = &x.f
  27. _ = !x.f
  28. (-x).f()
  29. (*x).f()
  30. (&x).f()
  31. (!x).f()
  32. _ = -x.f()
  33. _ = *x.f()
  34. _ = &x.f()
  35. _ = !x.f()
  36. _ = (-x).f
  37. _ = (*x).f
  38. _ = (&x).f
  39. _ = (!x).f
  40. _ = -x.f
  41. _ = *x.f
  42. _ = &x.f
  43. _ = !x.f
  44. (-x).f()
  45. (*x).f()
  46. (&x).f()
  47. (!x).f()
  48. _ = -x.f()
  49. _ = *x.f()
  50. _ = &x.f()
  51. _ = !x.f()
  52. _ = -x.f
  53. _ = *x.f
  54. _ = &x.f
  55. _ = !x.f
  56. _ = -x.f
  57. _ = *x.f
  58. _ = &x.f
  59. _ = !x.f
  60. _ = -x.f()
  61. _ = *x.f()
  62. _ = &x.f()
  63. _ = !x.f()
  64. _ = -x.f()
  65. _ = *x.f()
  66. _ = &x.f()
  67. _ = !x.f()
  68. }