aboutsummaryrefslogtreecommitdiffhomepage
path: root/errortest/badlib/versioned_impls.slul
blob: e8f5b5a1c86d309afda9ba242f9cfc4bfac7207e (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

#
# Implementation file of badlib
#
# 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.
#

# ERROR +2.53: error: Incompatible types. Arrays have mixed variable/non-variable lengths
# ERROR .7: error: Identifier value is not known at compile-time
data [external_value_ver]int typechk_array_extlen = []

func BadVersion1.some_private_function() -> bool
{
    return true
}

func BadLibClosedType.some_private_function() -> bool
{
    return this.x == 123
}

func use_nestedonly_lib()
{
    # ERROR .5: error: Identifier 'func_in_lib' does not exist
    func_in_lib()
}

func use_nestedonly_typeident()
{
    # ERROR .18: error: ".local_constructor" does not exist in the target type
    accept_type(.local_constructor())
    # ERROR .18: error: ".typeident1_constructor" does not exist in the target type
    accept_type(.typeident1_constructor())

    # ERROR +2.24: error: ".from_different_type" does not exist in the target type
    # ERROR .24: hint: Regarding missing identifier 'from_different_type' in type 'DiffType': A type with the same name also exists in module 'with_typeident_diff1'
    var DiffType dt = .from_different_type
}

# The nestedonly flag for withtypeident3 applies to our interface only
data NestedType use_iface_nestedonly = (.field = .nested_typeident_in_withtypeident3)
func func_use_iface_nestedonly()
{
    var NestedType use_iface_nestedonly = (.field = .nested_typeident_in_withtypeident3)
}

func use_conflicting_idents(
        # ERROR .17: error: Identifier 'Conflicting' is defined in more than one module
        ref var Conflicting confl_type,
        ref var PrivTypeVer confl_mth)
{
    # ERROR +2.16: error: Method "method_a" does not exist in type "Conflicting"
    # ERROR .16: hint: Regarding missing identifier 'method_a' in type 'Conflicting': A type with the same name also exists in module 'conflict1'
    confl_type.method_a()
    # Should not give a hint like above
    # ERROR .16: error: Method "missing_method" does not exist in type "Conflicting"
    confl_type.missing_method()

    # ERROR .15: error: Type identifier 'conflicting_method' in 'PrivTypeVer' is defined in more than one module
    confl_mth.conflicting_method()
}

func use_unavailable_versions()
{
    # 1.2   = the version specified as a dependency.
    # 2.0   = a chronologically earlier release with a higher (=unavailable) version number.
    # 0.9.1 = a chronologically later (=unavailable) release with a lower version number.
    # 2.1   = a relase that is both chronologically later and has a higher version number.

    # ERROR .9: error: Type 'TypeSince20' from module 'error_support_ver' isn't available in version 1.2. It was added in 2.0
    ref TypeSince20 obj1
    # ERROR .9: error: Type 'TypeSince091' from module 'error_support_ver' isn't available in version 1.2. It was added in a more recent (although lower) version 0.9.1
    ref TypeSince091 obj2
    # ERROR .5: error: Identifier 'func_since_20' from module 'error_support_ver' isn't available in version 1.2. It was added in 2.0
    func_since_20(123)
    # ERROR .5: error: Identifier 'func_since_091' from module 'error_support_ver' isn't available in version 1.2. It was added in a more recent (although lower) version 0.9.1
    func_since_091(123)
    # ERROR .13: error: Identifier 'external_value_since_20' from module 'error_support_ver' isn't available in version 1.2. It was added in 2.0
    int x = external_value_since_20
    # ERROR .13: error: Identifier 'external_value_since_091' from module 'error_support_ver' isn't available in version 1.2. It was added in a more recent (although lower) version 0.9.1
    int y = external_value_since_091
    var VersionedEnum enu
    enu = .a
    # ERROR .12: error: Identifier 'c_since091' in 'VersionedEnum' from module 'error_support_ver' isn't available in version 1.2. It was added in a more recent (although lower) version 0.9.1
    enu = .c_since091
    # ERROR .12: error: Identifier 'd_since21' in 'VersionedEnum' from module 'error_support_ver' isn't available in version 1.2. It was added in 2.1
    enu = .d_since21
    ref var VersionedStruct st = .defaults()
    st.a = 123
    st.b = true
    # ERROR .8: error: Field 'c_since091' in 'VersionedStruct' from module 'error_support_ver' isn't available in version 1.2. It was added in a more recent (although lower) version 0.9.1
    st.c_since091 = 456
    # ERROR .8: error: Field 'd_since21' in 'VersionedStruct' from module 'error_support_ver' isn't available in version 1.2. It was added in 2.1
    st.d_since21 = 789
    # ERROR .33: error: Identifier 'defaults_20' in 'VersionedStruct' from module 'error_support_ver' isn't available in version 1.2. It was added in 2.0
    ref VersionedStruct st20 = .defaults_20()
    # ERROR .34: error: Identifier 'defaults_091' in 'VersionedStruct' from module 'error_support_ver' isn't available in version 1.2. It was added in a more recent (although lower) version 0.9.1
    ref VersionedStruct st091 = .defaults_091()
}