# # Test .slul source file with invalid function/data declarations # # Copyright © 2023-2024 Samuel Lidén Borell # # 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