aboutsummaryrefslogtreecommitdiffhomepage
path: root/errortest/mainapp/decls.slul
blob: 95529531430bf52656ef2fdce49c7e1386f3ed50 (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

#
# Test .slul source file with invalid function/data declarations
#
# Copyright © 2023-2024 Samuel Lidén Borell <samuel@kodafritt.se>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

func decl_returntype_wrong_side()
{
    # ERROR .3: error: Unexpected symbol in top-level declaration
} decl_junk_at_end more_junk
more_junk

func decl_parser_recovery1() { }

# ERROR .1: error: Invalid start token at top level
void decl_voidstart()
{
}

func decl_parser_recovery2() { }

# ERROR .1: error: Invalid start token at top level
int decl_intstart()
{
}

# ERROR .37: error: Unexpected symbol at end of function declaration
func decl_bad_funcdecl_end() -> int xx
{
}

# ERROR .31: error: Unexpected symbol in top-level declaration
type DeclBadTypedeclEnd = int xx

# ERROR .25: error: There is no "void" type. Please remove.
func decl_ret_void() -> void
{
}

# ERROR .30: error: Expected "->" or valid keyword at end of function declaration
func decl_return_no_arrow () int
{
}

# ERROR .22: error: Incorrect syntax. Expected a type here.
func decl_typecolon1(x: int)
{
}

# ERROR +2.23: error: Expected an identifier here
# ERROR .22: error: Type 'X' does not exist
func decl_typecolon2(X: Integer)
{
}

# ERROR .6: error: Expected name, .name, or Class.name after "func"
func []int decl_returntype_wrong_side1()
{
}

# TODO improve this one. as long as it is "a.b()" then it should say something like "for methods, the first identifier should be the class/type, and types start with an uppercase letter"
# ERROR .29: error: Expected ( after function name
func decl_bad_lowercase_type.f()
{
}

# ERROR .7: error: Expected a non-type identifier here, but those are lower_case
func .DeclConstructorUpperCase()
{
}

# ERROR .23: error: Function names should be in lower case
func DeclFuncUpperCase()
{
}

# ERROR +2.5: error: Expected "{" before function body
func decl_missing_lcurly() -> int
    int x
}

# ERROR +2.33: error: Duplicate name of function parameter
# ERROR .26: <-- other definition: x
func decl_dupl_param(int x, int x) -> int {}

# ERROR .28: error: enums can only be defined with "type ... = enum { ... }"
func decl_enum_return() -> enum { a b } { while true { } }

func decl_parser_recovery3() { }

# ERROR .35: error: Open types can only be used inside a "ref"
func decl_open_paramtype(OpenType test) { }
# ERROR .42: error: Open types can only be used inside a "ref"
func decl_open_paramtype_ver(OpenTypeVer test) { }
# FIXME error column should be .32
# ERROR .6: error: Open types can only be used inside a "ref"
func decl_open_returntype() -> OpenType
{
    while true { }
}
# FIXME error column should be .36
# ERROR .6: error: Open types can only be used inside a "ref"
func decl_open_returntype_ver() -> OpenTypeVer
{
    while true { }
}

# ERROR .1: error: Invalid start token at top level
}

# ERROR .6: error: Expected a type here, but types must start with UpperCase
data i = 123

# ERROR +2.6: error: Type 'I' does not exist
# ERROR .7: error: Expected an identifier here
data I: Integer = 123

# ERROR .10: error: Expected an identifier here
data byte: integer = 123

# ERROR .12: error: Unexpected symbol after declaration. Expected '='
data int i == 1

# ERROR .7: error: References are not allowed as global/top-level data objects
data ?ref ClosedType ref_in_global_data = none
# ERROR .7: error: References are not allowed as global/top-level data objects
data ?funcref() funcref_in_global_data = none