1
0
mirror of https://github.com/golang/go synced 2024-11-17 22:05:02 -07:00
go/test/fixedbugs/issue32133.go
Robert Griesemer bfb903f252 cmd/compile/internal/syntax: better scanner error messages
This is one of several changes that were part of a larger rewrite
which I made in early 2019 after switching to the new number literal
syntax implementation. The purpose of the rewrite was to simplify
reading of source code (Unicode character by character) and speed up
the scanner but was never submitted for review due to other priorities.

Part 2 of 3:

This change contains improvements to the scanner error messages:

- Use "rune literal" rather than "character literal" to match the
  spec nomenclature.

- Shorter, more to the point error messages.
  (For instance, "more than one character in rune literal" rather
  than "invalid character literal (more than one character)", etc.)

Change-Id: I1aaf79003374a68dbb05926437ed305cf2a8ec96
Reviewed-on: https://go-review.googlesource.com/c/go/+/221602
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-03-05 00:40:38 +00:00

43 lines
718 B
Go

// errorcheck
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
// errors for the //line-adjusted code below
// ERROR "newline in string"
// ERROR "newline in character literal|newline in rune literal"
// ERROR "newline in string"
// ERROR "string not terminated"
//line :10:1
import "foo
//line :19:1
func _() {
0x // ERROR "hexadecimal literal has no digits"
}
func _() {
0x1.0 // ERROR "hexadecimal mantissa requires a 'p' exponent"
}
func _() {
0_i // ERROR "'_' must separate successive digits"
}
func _() {
//line :11:1
'
}
func _() {
//line :12:1
"
}
func _() {
//line :13:1
`