File: number_identifier_errors.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (74 lines) | stat: -rw-r--r-- 3,540 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// RUN: %target-typecheck-verify-swift

// Per rdar://problem/32316666 , it is a common mistake for beginners
// to start a function name with a number, so it's worth
// special-casing the diagnostic to make it clearer.

func 1() {}
// expected-error@-1 {{function name can only start with a letter or underscore, not a number}}
func 2.0() {}
// expected-error@-1 {{function name can only start with a letter or underscore, not a number}}
func 3func() {}
// expected-error@-1 {{function name can only start with a letter or underscore, not a number}}
// expected-error@-2 {{'f' is not a valid digit in integer literal}}

protocol 4 {
  // expected-error@-1 {{protocol name can only start with a letter or underscore, not a number}}
  associatedtype 5
  // expected-error@-1 {{associatedtype name can only start with a letter or underscore, not a number}}
}
protocol 6.0 {
  // expected-error@-1 {{protocol name can only start with a letter or underscore, not a number}}
  associatedtype 7.0
  // expected-error@-1 {{associatedtype name can only start with a letter or underscore, not a number}}
}
protocol 8protocol {
  // expected-error@-1 {{protocol name can only start with a letter or underscore, not a number}}
  // expected-error@-2 {{'p' is not a valid digit in integer literal}}
  associatedtype 9associatedtype
  // expected-error@-1 {{associatedtype name can only start with a letter or underscore, not a number}}
  // expected-error@-2 {{'a' is not a valid digit in integer literal}}
}

typealias 10 = Int
// expected-error@-1 {{typealias name can only start with a letter or underscore, not a number}}
typealias 11.0 = Int
// expected-error@-1 {{typealias name can only start with a letter or underscore, not a number}}
typealias 12typealias = Int
// expected-error@-1 {{typealias name can only start with a letter or underscore, not a number}}
// expected-error@-2 {{'t' is not a valid digit in integer literal}}

struct 13 {}
// expected-error@-1 {{struct name can only start with a letter or underscore, not a number}}
struct 14.0 {}
// expected-error@-1 {{struct name can only start with a letter or underscore, not a number}}
struct 15struct {}
// expected-error@-1 {{struct name can only start with a letter or underscore, not a number}}
// expected-error@-2 {{'s' is not a valid digit in integer literal}}

enum 16 {}
// expected-error@-1 {{enum name can only start with a letter or underscore, not a number}}
enum 17.0 {}
// expected-error@-1 {{enum name can only start with a letter or underscore, not a number}}
enum 18enum {}
// expected-error@-1 {{enum name can only start with a letter or underscore, not a number}}
// expected-error@-2 {{'n' is not a valid digit in floating point exponent}}

class 19 {
  // expected-error@-1 {{class name can only start with a letter or underscore, not a number}}
  func 20() {}
  // expected-error@-1 {{function name can only start with a letter or underscore, not a number}}
}
class 21.0 {
  // expected-error@-1 {{class name can only start with a letter or underscore, not a number}}
  func 22.0() {}
  // expected-error@-1 {{function name can only start with a letter or underscore, not a number}}
}

class 23class {
  // expected-error@-1 {{class name can only start with a letter or underscore, not a number}}
  // expected-error@-2 {{'c' is not a valid digit in integer literal}}
  func 24method() {}
  // expected-error@-1 {{function name can only start with a letter or underscore, not a number}}
  // expected-error@-2 {{'m' is not a valid digit in integer literal}}
}