compiler: improve error for import of non-string
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273867
This commit is contained in:
parent
66dde7bc64
commit
4f32eced9d
3 changed files with 6 additions and 34 deletions
|
@ -1,4 +1,4 @@
|
|||
16ab9b001c214cf831bc52a7bca5a2d18e9e4f3c
|
||||
534fb907c821b052dc430330708d7fa555b91fe3
|
||||
|
||||
The first line of this file holds the git revision number of the last
|
||||
merge done from the gofrontend repository.
|
||||
|
|
|
@ -5788,7 +5788,7 @@ Parse::import_spec(void*, unsigned int pragmas)
|
|||
|
||||
if (!token->is_string())
|
||||
{
|
||||
go_error_at(this->location(), "import statement not a string");
|
||||
go_error_at(this->location(), "import path must be a string");
|
||||
this->advance_token();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,35 +21,7 @@ import _ "go/parser"
|
|||
//import "greek/αβ"
|
||||
|
||||
// Import paths must be strings.
|
||||
import 42 // ERROR "import statement"
|
||||
import 'a' // ERROR "import statement"
|
||||
import 3.14 // ERROR "import statement"
|
||||
import 0.25i // ERROR "import statement"
|
||||
|
||||
// Each of these pairs tests both `` vs "" strings
|
||||
// and also use of invalid characters spelled out as
|
||||
// escape sequences and written directly.
|
||||
// For example `"\x00"` tests import "\x00"
|
||||
// while "`\x00`" tests import `<actual-NUL-byte>`.
|
||||
import "" // ERROR "import path"
|
||||
import `` // ERROR "import path"
|
||||
import "\x00" // ERROR "import path"
|
||||
import `\x00` // ERROR "import path"
|
||||
import "\x7f" // ERROR "import path"
|
||||
import `\x7f` // ERROR "import path"
|
||||
import "a!" // ERROR "import path"
|
||||
import `a!` // ERROR "import path"
|
||||
import "a b" // ERROR "import path"
|
||||
import `a b` // ERROR "import path"
|
||||
import "a\\b" // ERROR "import path"
|
||||
import `a\\b` // ERROR "import path"
|
||||
import "\"`a`\"" // ERROR "import path"
|
||||
import `\"a\"` // ERROR "import path"
|
||||
import "\x80\x80" // ERROR "import path"
|
||||
import `\x80\x80` // ERROR "import path"
|
||||
import "\xFFFD" // ERROR "import path"
|
||||
import `\xFFFD` // ERROR "import path"
|
||||
|
||||
// Invalid local imports.
|
||||
import "/foo" // ERROR "import path cannot be absolute path"
|
||||
import "c:/foo" // ERROR "import path contains invalid character"
|
||||
import 42 // ERROR "import path must be a string"
|
||||
import 'a' // ERROR "import path must be a string"
|
||||
import 3.14 // ERROR "import path must be a string"
|
||||
import 0.25i // ERROR "import path must be a string"
|
||||
|
|
Loading…
Add table
Reference in a new issue