-
Notifications
You must be signed in to change notification settings - Fork 20
/
DeadTest.res
187 lines (139 loc) · 3.24 KB
/
DeadTest.res
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
let _ = Js.log(ImmutableArray.fromArray)
let fortytwo = 42
@genType
let fortyTwoButExported = 42
let thisIsUsedOnce = 34
ignore(thisIsUsedOnce)
let thisIsUsedTwice = 34
ignore(thisIsUsedTwice)
ignore(thisIsUsedTwice)
@dead
let thisIsMarkedDead = 99
let thisIsKeptAlive = 42
@live
let thisIsMarkedLive = thisIsKeptAlive
module Inner = {
@dead
let thisIsAlsoMarkedDead = 99
}
module M: {
@dead
let thisSignatureItemIsDead: int
} = {
let thisSignatureItemIsDead = 34
}
module VariantUsedOnlyInImplementation: {
type t = A // TODO: discovered this automatically
let a: t
} = {
type t = A
let a = A
}
let _ = (x => x)(VariantUsedOnlyInImplementation.a)
let _ = DeadTypeTest.OnlyInInterface
let _ = DeadTypeTest.InBoth
type record = {
xxx: int,
yyy: int,
}
let _ = r => r.xxx
let _ = ({yyy}) => yyy
module UnderscoreInside = {
let _ = 13
}
module MM: {
let x: int
let y: int
} = {
let y = 55
let x = y
let valueOnlyInImplementation = 7
}
let _ = {
Js.log(MM.x)
44
}
let () = Js.log(DeadValueTest.valueAlive)
let rec unusedRec = () => unusedRec()
let rec split_map = l => {
let _ = split_map(l)
list{}
}
let rec rec1 = () => rec2()
and rec2 = () => rec1()
let rec recWithCallback = () => {
let cb = () => recWithCallback()
cb()
}
let rec foo = () => {
let cb = () => bar()
cb()
}
and bar = () => foo()
let withDefaultValue = (~paramWithDefault=3, y) => paramWithDefault + y
external unsafe_string1: (bytes, int, int) => Digest.t = "caml_md5_string"
module Ext_buffer: {
external unsafe_string2: (bytes, int, int) => Digest.t = "caml_md5_string"
} = {
external unsafe_string2: (bytes, int, int) => Digest.t = "caml_md5_string"
}
let () = Js.log(DeadRT.Root("xzz"))
module LazyDynamicallyLoadedComponent = %lazyLoadComponent(DynamicallyLoadedComponent)
module type LocalDynamicallyLoadedComponent2 = module type of DynamicallyLoadedComponent
module LazyDynamicallyLoadedComponent2 = {
let reasonResource: JSResource.t<
module(LocalDynamicallyLoadedComponent2),
> = JSResource.jSResource("DynamicallyLoadedComponent.bs")
let makeProps = DynamicallyLoadedComponent.makeProps
let make = props =>
React.createElement(
{
module Comp = unpack(BootloaderResource.read(reasonResource))
Comp.make
},
props,
)
}
let cmp = <LazyDynamicallyLoadedComponent s="hello" />
let cmp2 = () => <LazyDynamicallyLoadedComponent2 s="hello" />
let () = Js.log(cmp)
module Chat = {}
module ComponentSwitch = unpack(
%requireCond((#gk, "chat", {"false": DynamicallyLoadedComponent, "true": ExportWithRename}))
)
let zzz = {
let a1 = 1
let a2 = 2
let a3 = 3
}
let () = Js.log(<DynamicallyLoadedComponent s="" />)
let second = 1L
let minute = Int64.mul(60L, second)
let deadRef = ref(12)
let makeSwitch = ComponentSwitch.make
@react.component
let make = (~s) => React.string(s)
let () = Js.log(make)
let theSideEffectIsLogging = Js.log(123)
let stringLengthNoSideEffects = String.length("sdkdl")
module GloobLive = {
let globallyLive1 = 1
let globallyLive2 = 2
let globallyLive3 = 3
}
module WithInclude: {
type t = A
} = {
module T = {
type t = A
}
include T
}
Js.log(WithInclude.A)
@dead
let funWithInnerVars = () => {
let x = 34
let y = 36
x + y
}
type rc = {a:int}