Stabel

Check-in [2badc579e3]
Login
Overview
Comment:Change auto-generated ctor name for memberless structs. [c2996a5e70]
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2badc579e35dd65fee5f0c973ce9ee40de36146772e388ada32b7aa45de7a17f
User & Date: robin.hansen on 2021-09-18 10:28:59
Other Links: manifest | tags
Context
2021-09-20
16:18
Change order of fields for alias: metadata [c2996a5e70]. check-in: 24cb64e9da user: robin.hansen tags: trunk
2021-09-18
10:28
Change auto-generated ctor name for memberless structs. [c2996a5e70] check-in: 2badc579e3 user: robin.hansen tags: trunk
2021-09-16
14:30
Improved integer syntax. [55a5b57c3b]. check-in: 946bd10827 user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/Parser.elm from [e30ba16980] to [c92d858572].

871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
                        |> List.map Generic
                        |> LocalRef typeDef.name
                        |> NotStackRange

                ctorDef =
                    { name =
                        if List.isEmpty typeMembers then
                            typeDef.name

                        else
                            ">" ++ typeDef.name
                    , typeSignature =
                        AssociatedFunctionSignature.Verified
                            { input =
                                List.map (NotStackRange << Tuple.second) typeMembers







|







871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
                        |> List.map Generic
                        |> LocalRef typeDef.name
                        |> NotStackRange

                ctorDef =
                    { name =
                        if List.isEmpty typeMembers then
                            typeDef.name ++ ">"

                        else
                            ">" ++ typeDef.name
                    , typeSignature =
                        AssociatedFunctionSignature.Verified
                            { input =
                                List.map (NotStackRange << Tuple.second) typeMembers

Modified stdlib/src/core.stbl from [72fbb4caf8] to [ae46c9c3bd].

1
2
3
4

5

6
7
8
9
10
11
12
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
defmodule:
exposing:
  Bool
  True

  False

  not
  select
  if
  dip
  over
  drop2
  split
................................................................................

defstruct: True
defstruct: False

defmulti: not
type: Bool -- Bool
: True
  drop False
: False
  drop True

defmulti: select
type: Bool a a -- a
: True
  drop swap drop
: False
  rotate drop2
................................................................................
  swap
  
# numbers

defmulti: zero?
type: Int -- Bool
: Int( value 0 )
  drop True
: Int
  drop False 

def: int=
type: Int Int -- Bool
: - zero?

def: negate
type: Int -- Int




>

>







 







|

|







 







|

|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
defmodule:
exposing:
  Bool
  True
  True>
  False
  False>
  not
  select
  if
  dip
  over
  drop2
  split
................................................................................

defstruct: True
defstruct: False

defmulti: not
type: Bool -- Bool
: True
  drop False>
: False
  drop True>

defmulti: select
type: Bool a a -- a
: True
  drop swap drop
: False
  rotate drop2
................................................................................
  swap
  
# numbers

defmulti: zero?
type: Int -- Bool
: Int( value 0 )
  drop True>
: Int
  drop False>

def: int=
type: Int Int -- Bool
: - zero?

def: negate
type: Int -- Int

Modified stdlib/src/list.stbl from [ac6dd828cb] to [d0bea91b6e].

1
2
3
4

5
6
7
8
9
10
11
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
55
56
57
58
59
60
61
62
63
64
65
66
defmodule:
exposing:
  List
  NonEmpty

  >first
  first>
  >rest
  rest>
  Empty
  of-one
  of-two
................................................................................
: first a
: rest (List a)

defstruct: Empty

def: of-one
type: a -- (NonEmpty a)
: Empty >NonEmpty

def: of-two
type: a a -- (NonEmpty a)
: Empty >NonEmpty >NonEmpty

def: of-three
type: a a a -- (NonEmpty a)
: Empty >NonEmpty >NonEmpty >NonEmpty

def: ,
type: (List a) a -- (NonEmpty a)
: swap >NonEmpty

defmulti: fold
type: (List a) b [ a b -- b ] -- b
................................................................................
  pair/spill # rest Pair first b quot
  ! # rest Pair b
  swap pair/second> # rest b quot
  fold

def: reverse
type: (List a) -- (List a)
: Empty [ >NonEmpty ] fold

def: fold-reverse
type: (List a) b [ a b -- b ] -- b
: -rotate reverse rotate fold




>







 







|



|



|







 







|




1
2
3
4
5
6
7
8
9
10
11
12
..
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
..
56
57
58
59
60
61
62
63
64
65
66
67
defmodule:
exposing:
  List
  NonEmpty
  NonEmpty>
  >first
  first>
  >rest
  rest>
  Empty
  of-one
  of-two
................................................................................
: first a
: rest (List a)

defstruct: Empty

def: of-one
type: a -- (NonEmpty a)
: Empty> >NonEmpty

def: of-two
type: a a -- (NonEmpty a)
: Empty> >NonEmpty >NonEmpty

def: of-three
type: a a a -- (NonEmpty a)
: Empty> >NonEmpty >NonEmpty >NonEmpty

def: ,
type: (List a) a -- (NonEmpty a)
: swap >NonEmpty

defmulti: fold
type: (List a) b [ a b -- b ] -- b
................................................................................
  pair/spill # rest Pair first b quot
  ! # rest Pair b
  swap pair/second> # rest b quot
  fold

def: reverse
type: (List a) -- (List a)
: Empty> [ >NonEmpty ] fold

def: fold-reverse
type: (List a) b [ a b -- b ] -- b
: -rotate reverse rotate fold

Modified stdlib/src/maybe.stbl from [081e92a1e7] to [11fdd7a2d5].

1
2
3
4

5
6
7
8
9
10
11
defmodule:
exposing:
  Maybe
  Nothing

  map
  when-nothing
:

defunion: Maybe a
: a
: Nothing




>







1
2
3
4
5
6
7
8
9
10
11
12
defmodule:
exposing:
  Maybe
  Nothing
  Nothing>
  map
  when-nothing
:

defunion: Maybe a
: a
: Nothing

Modified tests/Test/Parser.elm from [e8a011aa46] to [b630228d82].

1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
....
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
....
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
....
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373

                        defstruct: True
                        defstruct: False

                        defmulti: from-int
                        type: Int -- Int
                        : Int( value 0 )
                          False
                        : Int
                          True

                        def: equal
                        : - from-int not

                        defmulti: not
                        : True
                          False
                        else: True
                        """

                    -- The ending source location for most definitions now ends where the next definition beings
                    -- This is not what we want (it includes too much white space), but it'll do for now.
                    expectedAst =
                        { sourceReference = ""
                        , moduleDefinition = ModuleDefinition.Undefined
................................................................................
                                  , documentation = ""
                                  , generics = []
                                  , members = AST.StructMembers []
                                  }
                                ]
                        , functions =
                            Dict.fromListBy .name
                                [ { name = "True"
                                  , typeSignature =
                                        AssociatedFunctionSignature.Verified
                                            { input = []
                                            , output = [ NotStackRange <| LocalRef "True" [] ]
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation = SoloImpl [ ConstructType "True" ]
                                  }
                                , { name = "False"
                                  , typeSignature =
                                        AssociatedFunctionSignature.Verified
                                            { input = []
                                            , output = [ NotStackRange <| LocalRef "False" [] ]
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
................................................................................
                                                        (SourceLocation 11 17)
                                                    )
                                                    (LocalRef "Int" [])
                                                    [ ( "value", LiteralInt 0 ) ]
                                              , [ Function
                                                    (SourceLocationRange
                                                        (SourceLocation 12 3)
                                                        (SourceLocation 12 8)
                                                    )
                                                    "False"
                                                ]
                                              )
                                            , ( TypeMatch
                                                    (SourceLocationRange
                                                        (SourceLocation 13 3)
                                                        (SourceLocation 13 6)
                                                    )
                                                    (LocalRef "Int" [])
                                                    []
                                              , [ Function
                                                    (SourceLocationRange
                                                        (SourceLocation 14 3)
                                                        (SourceLocation 14 7)
                                                    )
                                                    "True"
                                                ]
                                              )
                                            ]
                                            []
                                  }
                                , { name = "equal"
                                  , typeSignature = AssociatedFunctionSignature.NotProvided
................................................................................
                                                        (SourceLocation 20 7)
                                                    )
                                                    (LocalRef "True" [])
                                                    []
                                              , [ Function
                                                    (SourceLocationRange
                                                        (SourceLocation 21 3)
                                                        (SourceLocation 21 8)
                                                    )
                                                    "False"
                                                ]
                                              )
                                            ]
                                            [ Function
                                                (SourceLocationRange
                                                    (SourceLocation 22 7)
                                                    (SourceLocation 22 11)
                                                )
                                                "True"
                                            ]
                                  }
                                ]
                        }
                in
                case compileRetainLocations source of
                    Err _ ->







|

|






|
|







 







|











|







 







|

|












|

|







 







|

|






|

|







1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
....
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
....
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
....
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373

                        defstruct: True
                        defstruct: False

                        defmulti: from-int
                        type: Int -- Int
                        : Int( value 0 )
                          False>
                        : Int
                          True>

                        def: equal
                        : - from-int not

                        defmulti: not
                        : True
                          False>
                        else: True>
                        """

                    -- The ending source location for most definitions now ends where the next definition beings
                    -- This is not what we want (it includes too much white space), but it'll do for now.
                    expectedAst =
                        { sourceReference = ""
                        , moduleDefinition = ModuleDefinition.Undefined
................................................................................
                                  , documentation = ""
                                  , generics = []
                                  , members = AST.StructMembers []
                                  }
                                ]
                        , functions =
                            Dict.fromListBy .name
                                [ { name = "True>"
                                  , typeSignature =
                                        AssociatedFunctionSignature.Verified
                                            { input = []
                                            , output = [ NotStackRange <| LocalRef "True" [] ]
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation = SoloImpl [ ConstructType "True" ]
                                  }
                                , { name = "False>"
                                  , typeSignature =
                                        AssociatedFunctionSignature.Verified
                                            { input = []
                                            , output = [ NotStackRange <| LocalRef "False" [] ]
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
................................................................................
                                                        (SourceLocation 11 17)
                                                    )
                                                    (LocalRef "Int" [])
                                                    [ ( "value", LiteralInt 0 ) ]
                                              , [ Function
                                                    (SourceLocationRange
                                                        (SourceLocation 12 3)
                                                        (SourceLocation 12 9)
                                                    )
                                                    "False>"
                                                ]
                                              )
                                            , ( TypeMatch
                                                    (SourceLocationRange
                                                        (SourceLocation 13 3)
                                                        (SourceLocation 13 6)
                                                    )
                                                    (LocalRef "Int" [])
                                                    []
                                              , [ Function
                                                    (SourceLocationRange
                                                        (SourceLocation 14 3)
                                                        (SourceLocation 14 8)
                                                    )
                                                    "True>"
                                                ]
                                              )
                                            ]
                                            []
                                  }
                                , { name = "equal"
                                  , typeSignature = AssociatedFunctionSignature.NotProvided
................................................................................
                                                        (SourceLocation 20 7)
                                                    )
                                                    (LocalRef "True" [])
                                                    []
                                              , [ Function
                                                    (SourceLocationRange
                                                        (SourceLocation 21 3)
                                                        (SourceLocation 21 9)
                                                    )
                                                    "False>"
                                                ]
                                              )
                                            ]
                                            [ Function
                                                (SourceLocationRange
                                                    (SourceLocation 22 7)
                                                    (SourceLocation 22 12)
                                                )
                                                "True>"
                                            ]
                                  }
                                ]
                        }
                in
                case compileRetainLocations source of
                    Err _ ->

Modified tests/Test/Parser/Util.elm from [c45a582fc9] to [0c312f5c79].

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
                |> List.map Generic
                |> LocalRef name
                |> NotStackRange

        ctor =
            { name =
                if List.isEmpty members then
                    name

                else
                    ">" ++ name
            , typeSignature =
                AssociatedFunctionSignature.Verified
                    { input = List.map (NotStackRange << Tuple.second) members
                    , output = [ selfType ]







|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
                |> List.map Generic
                |> LocalRef name
                |> NotStackRange

        ctor =
            { name =
                if List.isEmpty members then
                    name ++ ">"

                else
                    ">" ++ name
            , typeSignature =
                AssociatedFunctionSignature.Verified
                    { input = List.map (NotStackRange << Tuple.second) members
                    , output = [ selfType ]

Modified tests/Test/TypeChecker.elm from [46133d700a] to [32cda2342c].

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
                        : head a
                        : rest (List a)

                        defstruct: Empty

                        def: main
                        type: -- Int
                        : 1 2 3 Empty >NonEmpty >NonEmpty >NonEmpty
                          0 [ + ] fold

                        defmulti: fold
                        type: (List a) b [ a b -- b ] -- b
                        : Empty
                          drop swap drop
                        : NonEmpty
................................................................................
                            type: (Maybe a) [ a -- b ] -- (Maybe b)
                            : a
                              !
                            : Nil
                              drop

                            def: main
                            : Nil [ 1 - ] map
                            """
                    in
                    expectTypeCheck input
            ]
        , describe "Recursive word definitions"
            [ test "With type annotation" <|
                \_ ->
................................................................................
                              swap rest> swap 
                              1 +
                              sum-helper
                            : EmptyList
                              swap drop

                            def: main
                            : 1 2 3 EmptyList >NonEmptyList >NonEmptyList >NonEmptyList
                              sum
                            """
                    in
                    expectTypeCheck input
            ]
        , test "Correct node types" <|
            \_ ->







|







 







|







 







|







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
                        : head a
                        : rest (List a)

                        defstruct: Empty

                        def: main
                        type: -- Int
                        : 1 2 3 Empty> >NonEmpty >NonEmpty >NonEmpty
                          0 [ + ] fold

                        defmulti: fold
                        type: (List a) b [ a b -- b ] -- b
                        : Empty
                          drop swap drop
                        : NonEmpty
................................................................................
                            type: (Maybe a) [ a -- b ] -- (Maybe b)
                            : a
                              !
                            : Nil
                              drop

                            def: main
                            : Nil> [ 1 - ] map
                            """
                    in
                    expectTypeCheck input
            ]
        , describe "Recursive word definitions"
            [ test "With type annotation" <|
                \_ ->
................................................................................
                              swap rest> swap 
                              1 +
                              sum-helper
                            : EmptyList
                              swap drop

                            def: main
                            : 1 2 3 EmptyList> >NonEmptyList >NonEmptyList >NonEmptyList
                              sum
                            """
                    in
                    expectTypeCheck input
            ]
        , test "Correct node types" <|
            \_ ->

Modified tests/Test/TypeChecker/Errors.elm from [7507f111d0] to [46be466d12].

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
                        def: main
                        type: -- out
                        : 0 true-or-false

                        defmulti: true-or-false
                        type: Int -- (Tmp a b)
                        : Int( value 0 )
                          drop False
                        : Int
                          drop True
                        """
                in
                Expect.equalLists
                    [ Problem.TypeError emptyRange
                        "main"
                        { input = [], output = [ Type.Generic "a" ] }
                        { input = []
................................................................................
                        defstruct: True
                        defstruct: False

                        defmulti: true-or-false
                        # should be Int -- Int (Maybe a)
                        type: Int -- Int
                        : Int( value 0 )
                          False
                        : Int
                          True
                        """
                in
                Expect.equalLists
                    [ Problem.TypeError emptyRange
                        "true-or-false"
                        { input = [ Type.Int ]
                        , output = [ Type.Int ]
................................................................................
                            type: (Maybe IntBox) Int -- Int
                            : IntBox( value Int( value 0 ) )
                              drop value>
                            : Nil
                              swap drop

                            def: main
                            : Nil 1 with-default
                            """

                        inexhaustiveError problem =
                            case problem of
                                Problem.InexhaustiveMultiFunction _ [ [ Type.Custom "IntBox", Type.Int ] ] ->
                                    True








|

|







 







|

|







 







|







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
                        def: main
                        type: -- out
                        : 0 true-or-false

                        defmulti: true-or-false
                        type: Int -- (Tmp a b)
                        : Int( value 0 )
                          drop False>
                        : Int
                          drop True>
                        """
                in
                Expect.equalLists
                    [ Problem.TypeError emptyRange
                        "main"
                        { input = [], output = [ Type.Generic "a" ] }
                        { input = []
................................................................................
                        defstruct: True
                        defstruct: False

                        defmulti: true-or-false
                        # should be Int -- Int (Maybe a)
                        type: Int -- Int
                        : Int( value 0 )
                          False>
                        : Int
                          True>
                        """
                in
                Expect.equalLists
                    [ Problem.TypeError emptyRange
                        "true-or-false"
                        { input = [ Type.Int ]
                        , output = [ Type.Int ]
................................................................................
                            type: (Maybe IntBox) Int -- Int
                            : IntBox( value Int( value 0 ) )
                              drop value>
                            : Nil
                              swap drop

                            def: main
                            : Nil> 1 with-default
                            """

                        inexhaustiveError problem =
                            case problem of
                                Problem.InexhaustiveMultiFunction _ [ [ Type.Custom "IntBox", Type.Int ] ] ->
                                    True

Modified tests/Test/TypeChecker/Unions.elm from [c778cb62b9] to [9955d381cb].

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
289
290
291
292
293
294
295
296
297
298
299
                        : False

                        defstruct: True
                        defstruct: False

                        defmulti: not
                        : True
                          drop False
                        : False
                          drop True

                        def: true-to-int
                        type: True -- Int
                        : drop 1

                        def: main
                        : True not true-to-int
                        """
                in
                expectTypeCheckFailure input
        , test "Generic union" <|
            \_ ->
                let
                    input =
................................................................................
                        type: (List a) a -- a
                        : NonEmptyList
                          drop first>
                        : EmptyList
                          swap drop

                        def: main
                        : 1 EmptyList >NonEmptyList
                          0 first-or-default
                          1 =
                        """
                in
                expectTypeCheck input
        , test "Union with generic branch" <|
            \_ ->
................................................................................
                        type: (Maybe a) a -- a
                        : a
                          drop
                        : Nil
                          swap drop

                        def: main
                        : Nil 1 with-default
                        """

                    nilTypeDef =
                        { name = "Nil"
                        , exposed = True
                        , generics = []
                        , sourceLocation = emptyRange
                        , members = QAST.StructMembers []
                        }

                    nilCtorDef =
                        { name = "Nil"
                        , type_ = { input = [], output = [ Type.Custom "Nil" ] }
                        , sourceLocation = Nothing
                        , implementation =
                            SoloImpl
                                [ ConstructType nilTypeDef ]
                        }

................................................................................
    : True
    : False

    defstruct: True
    defstruct: False

    def: main
    : True to-int
      False to-int
      =
    """







|

|






|







 







|







 







|











|







 







|
|


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
289
290
291
292
293
294
295
296
297
298
299
                        : False

                        defstruct: True
                        defstruct: False

                        defmulti: not
                        : True
                          drop False>
                        : False
                          drop True>

                        def: true-to-int
                        type: True -- Int
                        : drop 1

                        def: main
                        : True> not true-to-int
                        """
                in
                expectTypeCheckFailure input
        , test "Generic union" <|
            \_ ->
                let
                    input =
................................................................................
                        type: (List a) a -- a
                        : NonEmptyList
                          drop first>
                        : EmptyList
                          swap drop

                        def: main
                        : 1 EmptyList> >NonEmptyList
                          0 first-or-default
                          1 =
                        """
                in
                expectTypeCheck input
        , test "Union with generic branch" <|
            \_ ->
................................................................................
                        type: (Maybe a) a -- a
                        : a
                          drop
                        : Nil
                          swap drop

                        def: main
                        : Nil> 1 with-default
                        """

                    nilTypeDef =
                        { name = "Nil"
                        , exposed = True
                        , generics = []
                        , sourceLocation = emptyRange
                        , members = QAST.StructMembers []
                        }

                    nilCtorDef =
                        { name = "Nil>"
                        , type_ = { input = [], output = [ Type.Custom "Nil" ] }
                        , sourceLocation = Nothing
                        , implementation =
                            SoloImpl
                                [ ConstructType nilTypeDef ]
                        }

................................................................................
    : True
    : False

    defstruct: True
    defstruct: False

    def: main
    : True> to-int
      False> to-int
      =
    """

Modified wasm_tests/module_resolution.test.js from [9bae11ca61] to [979dc2e0f5].

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
                package: 'author/sample',
                module: 'core',
                source: `
                    defstruct: Todo
                    : marker mod/Tipe

                    def: main
                    : mod/Tipe
                      1 mod/>TipeGen
                      mod/Tipe
                      2 mod/>TipeGen
                      drop-tipes
                      tipe-int

                    def: drop-tipes
                    type: (mod/TipeGen a) mod/Tipe (mod/TipeU a) --
                    : drop drop drop
................................................................................
                package: 'author/sample',
                module: 'core',
                source: `
                    defstruct: Todo
                    : marker /mod/Tipe

                    def: main
                    : /mod/Tipe
                      1 /mod/>TipeGen
                      /mod/Tipe
                      2 /mod/>TipeGen
                      drop-tipes
                      tipe-int

                    def: drop-tipes
                    type: (/mod/TipeGen a) /mod/Tipe (/mod/TipeU a) --
                    : drop drop drop







|

|







 







|

|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
                package: 'author/sample',
                module: 'core',
                source: `
                    defstruct: Todo
                    : marker mod/Tipe

                    def: main
                    : mod/Tipe>
                      1 mod/>TipeGen
                      mod/Tipe>
                      2 mod/>TipeGen
                      drop-tipes
                      tipe-int

                    def: drop-tipes
                    type: (mod/TipeGen a) mod/Tipe (mod/TipeU a) --
                    : drop drop drop
................................................................................
                package: 'author/sample',
                module: 'core',
                source: `
                    defstruct: Todo
                    : marker /mod/Tipe

                    def: main
                    : /mod/Tipe>
                      1 /mod/>TipeGen
                      /mod/Tipe>
                      2 /mod/>TipeGen
                      drop-tipes
                      tipe-int

                    def: drop-tipes
                    type: (/mod/TipeGen a) /mod/Tipe (/mod/TipeU a) --
                    : drop drop drop

Modified wasm_tests/multifunctions.test.js from [05dafe1e7c] to [b56d183212].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
        defmulti: to-int
        : True
          drop 100
        : False
          drop 75

        def: main
        : True to-int 
          False to-int 
          -
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(25);
});
................................................................................

        defmulti: to-int
        : True
          drop 100
        else: drop 75

        def: main
        : True to-int 
          False to-int 
          -
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(25);
});
................................................................................
        defmulti: first-or-default
        : NonEmptyList
          drop first>
        : EmptyList
          swap drop

        def: main
        : 1 EmptyList >NonEmptyList
          0 first-or-default
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(1);
});
................................................................................
        type: (List a) Int -- Int
        : NonEmptyList
          swap dup first> rotate rest> rotate + sum-helper
        : EmptyList
          swap drop

        def: main
        : 1 2 3 EmptyList >NonEmptyList >NonEmptyList >NonEmptyList
          sum
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(6);
});
................................................................................
        : Int( value 0 )
          swap 
          drop 1
          swap
        : Int

        def: main
        : 0 Nil inc-zero
          drop 
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(1);
});







|
|







 







|
|







 







|







 







|







 







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
        defmulti: to-int
        : True
          drop 100
        : False
          drop 75

        def: main
        : True> to-int 
          False> to-int 
          -
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(25);
});
................................................................................

        defmulti: to-int
        : True
          drop 100
        else: drop 75

        def: main
        : True> to-int 
          False> to-int 
          -
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(25);
});
................................................................................
        defmulti: first-or-default
        : NonEmptyList
          drop first>
        : EmptyList
          swap drop

        def: main
        : 1 EmptyList> >NonEmptyList
          0 first-or-default
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(1);
});
................................................................................
        type: (List a) Int -- Int
        : NonEmptyList
          swap dup first> rotate rest> rotate + sum-helper
        : EmptyList
          swap drop

        def: main
        : 1 2 3 EmptyList> >NonEmptyList >NonEmptyList >NonEmptyList
          sum
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(6);
});
................................................................................
        : Int( value 0 )
          swap 
          drop 1
          swap
        : Int

        def: main
        : 0 Nil> inc-zero
          drop 
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(1);
});

Modified wasm_tests/pattern_match.test.js from [ce9d875c1d] to [5f9eb61ab9].

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
...
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
        : Nothing
          swap drop

        def: main
        : 5
          10 with-default

          Nothing
          10 with-default

          +
    `);

    const result = await compiler.run(wat, 'main');

................................................................................
        : Nothing
          swap drop

        def: main
        : 5
          10 with-default

          Nothing
          10 with-default

          +
    `);

    const result = await compiler.run(wat, 'main');

................................................................................
        else: 
          swap drop

        def: main
        : 5
          15 with-default

          Nothing
          2 with-default

          +
    `);

    const result = await compiler.run(wat, 'main');

................................................................................
        defstruct: Box
        : value Bool

        defmulti: true?
        type: Box -- Bool
        : Box( value True )
          value>
        else: drop False

        defmulti: as-int
        type: Bool -- Int
        : True
          drop 20
        : False
          drop 10

        def: main
        : True >Box
          true? as-int
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(20);
});







|







 







|







 







|







 







|









|







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
...
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
        : Nothing
          swap drop

        def: main
        : 5
          10 with-default

          Nothing>
          10 with-default

          +
    `);

    const result = await compiler.run(wat, 'main');

................................................................................
        : Nothing
          swap drop

        def: main
        : 5
          10 with-default

          Nothing>
          10 with-default

          +
    `);

    const result = await compiler.run(wat, 'main');

................................................................................
        else: 
          swap drop

        def: main
        : 5
          15 with-default

          Nothing>
          2 with-default

          +
    `);

    const result = await compiler.run(wat, 'main');

................................................................................
        defstruct: Box
        : value Bool

        defmulti: true?
        type: Box -- Bool
        : Box( value True )
          value>
        else: drop False>

        defmulti: as-int
        type: Bool -- Int
        : True
          drop 20
        : False
          drop 10

        def: main
        : True> >Box
          true? as-int
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(20);
});

Modified wasm_tests/structs.test.js from [95364b6e75] to [73522f7d99].

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

test('Enum type', async () => {
    const wat = await compiler.toWat('main', `
       defstruct: True 
       defstruct: False

       def: main
       : True
    `);

    const result = await compiler.run(wat, 'main');

    // types are sorted alphabetically, so False will get id 0, and True gets id 1.
    expect(result.typeIdForPointer()).toBe(1);
});

test('Struct with annotations', async () => {
    const wat = await compiler.toWat('main', `
        defstruct: True

        def: main
        : True as-int

        def: as-int
        type: True -- Int
        : drop 1
    `);

    const result = await compiler.run(wat, 'main');







|













|







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

test('Enum type', async () => {
    const wat = await compiler.toWat('main', `
       defstruct: True 
       defstruct: False

       def: main
       : True>
    `);

    const result = await compiler.run(wat, 'main');

    // types are sorted alphabetically, so False will get id 0, and True gets id 1.
    expect(result.typeIdForPointer()).toBe(1);
});

test('Struct with annotations', async () => {
    const wat = await compiler.toWat('main', `
        defstruct: True

        def: main
        : True> as-int

        def: as-int
        type: True -- Int
        : drop 1
    `);

    const result = await compiler.run(wat, 'main');