Skip to content

Commit 9c7c58c

Browse files
authored
Allow type expansion of variants. (#805)
1 parent a2297c0 commit 9c7c58c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+969
-374
lines changed

core/tests/tests/Decoding.mint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ suite "Decode" {
1212

1313
test "it decode simple variant" {
1414
let object =
15-
`{ type: "EncodeTestVariants.Variant2" }`
15+
`{ type: "Variant2" }`
1616

1717
decode object as EncodeTestVariants == Result.Ok(
1818
EncodeTestVariants.Variant2)
1919
}
2020

2121
test "it decodes complex variant" {
2222
let object =
23-
`{ type: "EncodeTestVariants.Variant3", value: ["Joe", 42] }`
23+
`{ type: "Variant3", value: ["Joe", 42] }`
2424

2525
decode object as EncodeTestVariants == Result.Ok(
2626
EncodeTestVariants.Variant3("Joe", 42))
2727
}
2828

2929
test "it decodes record variant" {
3030
let object =
31-
`{ type: "EncodeTestVariants.Variant1", value: ["Joe", 42] }`
31+
`{ type: "Variant1", value: ["Joe", 42] }`
3232

3333
decode object as EncodeTestVariants == Result.Ok(
3434
EncodeTestVariants.Variant1("Joe", 42))

core/tests/tests/Encoding.mint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ suite "Encode" {
9494
let encoded =
9595
encode EncodeTestVariants.Variant2
9696

97-
`#{encoded}.type` == "EncodeTestVariants.Variant2"
97+
`#{encoded}.type` == "Variant2"
9898
}
9999
}

spec/compilers/block_with_early_return

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import {
2121
} from "./runtime.js";
2222

2323
export const
24-
F = A(1, `Test.A`),
25-
G = A(1, `Test.B`),
24+
F = A(1, `A`),
25+
G = A(1, `B`),
2626
H = () => {
2727
const a = B(C(F)(`Some string...`), D(F, [E]));
2828
if (a === false) {

spec/compilers/block_with_early_return_await

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import {
2525
} from "./runtime.js";
2626

2727
export const
28-
F = A(1, `Test.A`),
29-
G = A(1, `Test.B`),
28+
F = A(1, `A`),
29+
G = A(1, `B`),
3030
H = () => {
3131
(async () => {
3232
const a = B(await C(F)(`Some string...`), D(F, [E]));

spec/compilers/block_with_fallback

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ import {
2424
} from "./runtime.js";
2525

2626
export const
27-
F = A(0, `Maybe.Nothing`),
28-
G = A(1, `Maybe.Just`),
27+
F = A(1, `Just`),
28+
G = A(0, `Nothing`),
2929
H = () => {
3030
const a = () => {
3131
return B(`span`, {}, [`Fallback`])
3232
};
33-
const b = C(D(G)(``), E(G, [null]));
33+
const b = C(D(F)(``), E(F, [null]));
3434
if (b === false) {
3535
return a()
3636
};
3737
const [] = b;
38-
const c = C(D(G)(``), E(G, [null]));
38+
const c = C(D(F)(``), E(F, [null]));
3939
if (c === false) {
4040
return a()
4141
};

spec/compilers/bracket_access

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ import {
2626
} from "./runtime.js";
2727

2828
export const
29-
D = A(0, `Maybe.Nothing`),
30-
E = A(1, `Maybe.Just`),
29+
D = A(1, `Just`),
30+
E = A(0, `Nothing`),
3131
F = () => {
3232
B([
3333
`Hello`,
3434
`Blah`,
3535
`Joe`
36-
], 1, E, D);
37-
B([], 1, E, D);
36+
], 1, D, E);
37+
B([], 1, D, E);
3838
C([[
3939
`key`,
4040
`value`
41-
]], `key`, E, D);
41+
]], `key`, D, E);
4242
return ``
4343
};

spec/compilers/bundling

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,48 @@ component Main {
5757
--------------------------------------------------------------------------------
5858
---=== /__mint__/index.js ===---
5959
import {
60-
lazyComponent as H,
61-
createElement as F,
62-
useEffect as D,
63-
useSignal as C,
64-
fragment as G,
65-
variant as I,
66-
record as A,
67-
load as E,
68-
lazy as B
60+
lazyComponent as I,
61+
createElement as G,
62+
useEffect as E,
63+
useSignal as D,
64+
fragment as H,
65+
variant as A,
66+
record as B,
67+
load as F,
68+
lazy as C
6969
} from "./runtime.js";
7070

7171
export const
72-
a = A(`User`),
72+
J = A(0, `Loaded`),
73+
K = A(0, `Loading`),
74+
a = B(`User`),
7375
b = `./1.js`,
7476
c = (d) => {
7577
return `Hello ${d}!`
7678
},
77-
J = B(`./2.js`),
78-
K = () => {
79-
const e = C(``);
80-
D(() => {
79+
L = C(`./2.js`),
80+
M = () => {
81+
const e = D(``);
82+
E(() => {
8183
(async () => {
82-
const f = await E(b);
84+
const f = await F(b);
8385
return (() => {
8486
e.value = f
8587
})()
8688
})()
8789
}, []);
88-
return F(G, {}, [
89-
F(H, {
90+
return G(H, {}, [
91+
G(I, {
9092
c: [],
9193
key: `Greeter`,
9294
p: {
9395
a: `World`
9496
},
95-
x: J
97+
x: L
9698
}),
9799
c(`Me`)
98100
])
99-
},
100-
L = I(0, `Status.Loading`),
101-
M = I(0, `Status.Loaded`);
101+
};
102102

103103
---=== /__mint__/1.js ===---
104104
export const a = `Hello, I was loaded later...`;

spec/compilers/case_or

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {
2020
} from "./runtime.js";
2121

2222
export const
23-
E = A(0, `A.B`),
24-
F = A(0, `A.C`),
25-
G = A(0, `A.D`),
23+
E = A(0, `B`),
24+
F = A(0, `C`),
25+
G = A(0, `D`),
2626
H = () => {
2727
return B(new E(), [[
2828
C([

spec/compilers/case_with_type_destructuring

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import {
3131
} from "./runtime.js";
3232

3333
export const
34-
F = A(1, `A.B`),
35-
G = A(1, `C.D`),
36-
H = A(0, `C.X`),
34+
F = A(1, `B`),
35+
G = A(1, `D`),
36+
H = A(0, `X`),
3737
I = () => {
3838
B(C(G)(C(F)(``)), [
3939
[

spec/compilers/component_instance_access

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import {
4040
} from "./runtime.js";
4141

4242
export const
43-
I = A(1, `Maybe.Just`),
44-
J = A(0, `Maybe.Nothing`),
43+
I = A(1, `Just`),
44+
J = A(0, `Nothing`),
4545
K = ({
4646
_
4747
}) => {

0 commit comments

Comments
 (0)