Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 \subsection*{Expression typing: $\yieldsOk{\Phi, \Delta, \Gamma}{e}{\opt{\tau}}{ e'}{\tau'}$} \hrulefill | |
| 2 | |
| 3 Expression typing is a relation between typing contexts, a term ($e$), an | |
| 4 optional type ($\opt{\tau}$), and a type ($\tau'$). The term $e$ represents the | |
| 5 term being checked. The optional type $\opt{\tau}$ is the type against which | |
| 6 the term is being checked (if present). The output type $\tau'$ is the most | |
| 7 precise type synthesized for the term. It should always be the case that the | |
| 8 synthesized (output) type is a subtype of the checked (input) type if the latter | |
| 9 is present. The checking/synthesis pattern allows for the propogation of type | |
| 10 information both downwards and upwards. It is often the case that downwards | |
| 11 propogation is not useful. Consequently, to simplify the presentation the rules | |
| 12 which do not use the checking type require that it be empty ($\_$). The first | |
| 13 typing rule allows contextual type information to be dropped so that such rules | |
| 14 apply in the cast that we have contextual type information, subject to the | |
| 15 contextual type being a supertype of the synthesized type: | |
| 16 | |
| 17 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\sigma} \quad\quad | |
| 18 \subtypeOf{\Phi, \Delta}{\sigma}{\tau} | |
| 19 } | |
| 20 {\yieldsOk{\Phi, \Delta, \Gamma}{e}{\tau}{e'}{\sigma}} | |
| 21 | |
| 22 The implicit downcast rule also allows this when the contextual type is a | |
| 23 subtype of the synthesized type, corresponding to an implicit downcast. | |
|
vsm
2015/07/13 22:36:56
As with the optional typing, I wonder if it's bett
Leaf
2015/07/14 22:39:49
Yes, I have mental note to revisit this. We can h
| |
| 24 | |
| 25 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\sigma} \quad\quad | |
| 26 \subtypeOf{\Phi, \Delta}{\tau}{\sigma} | |
| 27 } | |
| 28 {\yieldsOk{\Phi, \Delta, \Gamma}{e}{\tau}{\echeck{e'}{\tau}}{\tau}} | |
| 29 | |
| 30 Variables are typed according to their declarations: | |
| 31 | |
| 32 \axiom{\yieldsOk{\Phi, \Delta, \extends{\Gamma}{x}{\tau}}{x}{\_}{x}{\tau}} | |
|
vsm
2015/07/13 22:36:56
There is type promotion - but perhaps that's ortho
Leaf
2015/07/14 22:39:49
Yes, I could formalize this, but it will take a fa
| |
| 33 | |
| 34 Numbers, booleans, and null all have a fixed synthesized type. | |
| 35 | |
| 36 \axiom{\yieldsOk{\Phi, \Delta, \Gamma}{i}{\_}{i}{\Num}} | |
| 37 | |
| 38 \axiom{\yieldsOk{\Phi, \Delta, \Gamma}{\eff}{\_}{\eff}{\Bool}} | |
| 39 | |
| 40 \axiom{\yieldsOk{\Phi, \Delta, \Gamma}{\ett}{\_}{\ett}{\Bool}} | |
| 41 | |
| 42 \axiom{\yieldsOk{\Phi, \Delta, \Gamma}{\enull}{\_}{\enull}{\Bottom}} | |
| 43 | |
| 44 A $\ethis$ expression is well-typed if we are inside of a method, and $\sigma$ | |
| 45 is the type of the enclosing class. | |
| 46 | |
| 47 \infrule{\Gamma = \Gamma'_{\sigma} | |
| 48 } | |
| 49 { | |
| 50 \yieldsOk{\Phi, \Delta, \Gamma}{\ethis}{\_}{\ethis}{\sigma} | |
| 51 } | |
| 52 | |
| 53 A fully annotated function is well-typed if its body is well-typed at its | |
| 54 declared return type, under the assumption that the variables have their | |
| 55 declared types. | |
| 56 | |
| 57 \infrule{\Gamma' = \extends{\Gamma}{\many{x}}{\many{\tau}} \quad | |
| 58 \yieldsOk{\Phi, \Delta, \Gamma'}{e}{\sigma}{e'}{\sigma'} | |
| 59 } | |
| 60 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 61 {\elambda{\many{x:\tau}}{\sigma}{e}} | |
| 62 {\_} | |
| 63 {\elambda{\many{x:\tau}}{\sigma}{e'}} | |
| 64 {\Arrow[-]{\many{\tau}}{\sigma}} | |
|
vsm
2015/07/13 22:36:56
Should this be \sigma_'_?
Leaf
2015/07/14 22:39:50
I think it *can* be, but not sure that it *should*
| |
| 65 } | |
| 66 | |
| 67 A function with a missing argument type is well-typed if it is well-typed with | |
| 68 the argument type replaced with $\Dynamic$. | |
| 69 | |
| 70 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 71 {\elambda{x_0:\opt{\tau_0}, \ldots, x_i:\Dynamic, \ldots, x_n: \opt{\tau_n}}{\opt{\sigma}}{e}} | |
| 72 {\opt{\tau}} | |
| 73 {e_f} | |
| 74 {\tau_f} | |
| 75 } | |
| 76 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 77 {\elambda{x_0:\opt{\tau_0}, \ldots, x_i:\_, \ldots, x_n:\opt{\ tau_n}}{\opt{\sigma}}{e}} | |
| 78 {\opt{\tau}} | |
| 79 {e_f} | |
| 80 {\tau_f} | |
| 81 } | |
| 82 | |
| 83 A function with a missing argument type is well-typed if it is well-typed with | |
| 84 the argument type replaced with the corresponding argument type from the context | |
| 85 type. Note that this rule overlaps with the previous: the formal presentation | |
| 86 leaves this as a non-deterministic choice. | |
|
vsm
2015/07/13 22:36:56
Is this a step toward downward inference?
Leaf
2015/07/14 22:39:49
This is downwards inference. It's specified in a
vsm
2015/07/15 18:25:34
So, if my expr is:
(e) => e.foo
and my contextua
Leaf
2015/07/15 22:27:25
As currently specified, it will type check, and wi
| |
| 87 | |
| 88 \infrule{\tau_c = \Arrow[k]{\upsilon_0, \ldots, \upsilon_n}{\upsilon_r} \\ | |
| 89 \yieldsOk{\Phi, \Delta, \Gamma} | |
| 90 {\elambda{x_0:\opt{\tau_0}, \ldots, x_i:\upsilon_i, \ldots, x_ n:\opt{\tau_n}}{\opt{\sigma}}{e}} | |
| 91 {\tau_c} | |
| 92 {e_f} | |
| 93 {\tau_f} | |
| 94 } | |
| 95 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 96 {\elambda{x_0:\opt{\tau_0}, \ldots, x_i:\_, \ldots, x_n:\opt{\ tau_n}}{\opt{\sigma}}{e}} | |
| 97 {\tau_c} | |
| 98 {e_f} | |
| 99 {\tau_f} | |
| 100 } | |
| 101 | |
| 102 A function with a missing return type is well-typed if it is well-typed with | |
| 103 the return type replaced with $\Dynamic$. | |
| 104 | |
| 105 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 106 {\elambda{\many{x:\opt{\tau}}}{\Dynamic}{e}} | |
| 107 {\opt{\tau_c}} | |
| 108 {e_f} | |
| 109 {\tau_f} | |
| 110 } | |
| 111 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 112 {\elambda{\many{x:\opt{\tau}}}{\_}{e}} | |
| 113 {\opt{\tau_c}} | |
| 114 {e_f} | |
| 115 {\tau_f} | |
| 116 } | |
| 117 | |
| 118 A function with a missing return type is well-typed if it is well-typed with | |
| 119 the return type replaced with the corresponding return type from the context | |
| 120 type. Note that this rule overlaps with the previous: the formal presentation | |
| 121 leaves this as a non-deterministic choice. | |
| 122 | |
| 123 \infrule{\tau_c = \Arrow[k]{\upsilon_0, \ldots, \upsilon_n}{\upsilon_r} \\ | |
| 124 \yieldsOk{\Phi, \Delta, \Gamma} | |
| 125 {\elambda{\many{x:\opt{\tau}}}{\upsilon_r}{e}} | |
| 126 {\tau_c} | |
| 127 {e_f} | |
| 128 {\tau_f} | |
| 129 } | |
| 130 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 131 {\elambda{\many{x:\opt{\tau}}}{\_}{e}} | |
| 132 {\tau_c} | |
| 133 {e_f} | |
| 134 {\tau_f} | |
| 135 } | |
| 136 | |
| 137 | |
| 138 Instance creation creates an instance of the appropriate type. | |
| 139 | |
| 140 % FIXME(leafp): inference | |
| 141 % FIXME(leafp): deal with bounds | |
| 142 \infrule{(C : \dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\upsilon_0, \ldots, \u psilon_k}}{\ldots}) \in \Phi \\ | |
| 143 \mbox{len}(\many{\tau}) = n+1} | |
| 144 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 145 {\enew{C}{\many{\tau}}{}} | |
| 146 {\_} | |
| 147 {\enew{C}{\many{\tau}}{}} | |
| 148 {\TApp{C}{\many{\tau}}} | |
| 149 } | |
| 150 | |
| 151 | |
| 152 Members of the set of primitive operations (left unspecified) can only be | |
| 153 applied. Applications of primitives are well-typed if the arguments are | |
| 154 well-typed at the types given by the signature of the primitive. | |
|
vsm
2015/07/13 22:36:56
In Dart, these are really just syntactic sugar for
Leaf
2015/07/14 22:39:49
These really model the underlying primitive operat
| |
| 155 | |
| 156 \infrule{\phi\, :\, \Arrow[]{\many{\tau}}{\sigma} \quad | |
| 157 \yieldsOk{\Phi, \Delta, \Gamma}{e}{\tau}{e'}{\tau'} | |
| 158 } | |
| 159 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 160 {\eprimapp{\phi}{\many{e}}} | |
| 161 {\_} | |
| 162 {\eprimapp{\phi}{\many{e'}}} | |
| 163 {\sigma} | |
| 164 } | |
| 165 | |
| 166 Function applications are well-typed if the applicand is well-typed and has | |
| 167 function type, and the arguments are well-typed. | |
| 168 | |
| 169 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 170 {e} | |
| 171 {\_} | |
| 172 {e'} | |
| 173 {\Arrow[k]{\many{\tau_a}}{\tau_r}} \quad\quad | |
| 174 \yieldsOk{\Phi, \Delta, \Gamma} | |
| 175 {e_a} | |
| 176 {\tau_a} | |
| 177 {e_a'} | |
| 178 {\tau_a'} \quad \mbox{for}\ e_a, \tau_a \in \many{e_a}, \many{ \tau_a} | |
| 179 \iftrans{\\ e_c = \begin{cases} | |
| 180 \ecall{e'}{\many{e_a'}} & \text{if $k = -$}\\ | |
| 181 \edcall{e'}{\many{e_a'}} & \text{if $k = +$} | |
| 182 \end{cases}} | |
| 183 } | |
| 184 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 185 {\ecall{e}{\many{e_a}}} | |
| 186 {\_} | |
| 187 {e_c} | |
| 188 {\tau_r} | |
| 189 } | |
| 190 | |
| 191 Application of an expression of type $\Dynamic$ is well-typed if the arguments | |
| 192 are well-typed at any type. | |
| 193 | |
| 194 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 195 {e} | |
| 196 {\_} | |
| 197 {e'} | |
| 198 {\Dynamic} \quad\quad | |
| 199 \yieldsOk{\Phi, \Delta, \Gamma} | |
| 200 {e_a} | |
| 201 {\_} | |
| 202 {e_a'} | |
| 203 {\tau_a'} \quad \mbox{for}\ e_a \in \many{e_a} | |
| 204 } | |
| 205 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 206 {\ecall{e}{\many{e_a}}} | |
| 207 {\_} | |
| 208 {\edcall{e'}{\many{e_a'}}} | |
| 209 {\Dynamic} | |
| 210 } | |
| 211 | |
| 212 A dynamic call expression is well-typed so long as the applicand and the | |
| 213 arguments are well-typed at any type. | |
|
vsm
2015/07/13 22:36:56
What does dcall add if you allow e to be dynamic a
Leaf
2015/07/14 22:39:49
Basically I'm anticipating the dynamic semantics (
Siggi Cherem (dart-lang)
2015/07/14 23:59:21
Makes sense - I think it might be worth splitting
vsm
2015/07/15 18:25:34
It's the same thing (I think), but it might be a l
Leaf
2015/07/15 22:27:25
Yes, this is reasonable. I need additional mechan
Leaf
2015/07/15 22:27:25
Done.
| |
| 214 | |
| 215 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 216 {e} | |
| 217 {\_} | |
| 218 {e'} | |
| 219 {\tau} \quad | |
| 220 \yieldsOk{\Phi, \Delta, \Gamma} | |
| 221 {e_a} | |
| 222 {\_} | |
| 223 {e_a'} | |
| 224 {\tau_a} \quad \mbox{for}\ e_a \in \many{e_a} | |
| 225 } | |
| 226 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 227 {\edcall{e}{\many{e_a}}} | |
| 228 {\_} | |
| 229 {\edcall{e'}{\many{e_a'}}} | |
| 230 {\Dynamic} | |
| 231 } | |
| 232 | |
| 233 A field load is well-typed if the term is well-typed, and the field name is | |
| 234 present in the type of the term. | |
| 235 | |
| 236 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 237 {e} | |
| 238 {\_} | |
| 239 {e'} | |
| 240 {\sigma} \quad\quad | |
| 241 \fieldLookup{\Phi}{\sigma}{m}{\tau} | |
| 242 } | |
| 243 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 244 {\eload{e}{m}} | |
| 245 {\_} | |
| 246 {\eload{e'}{m}} | |
| 247 {\tau} | |
| 248 } | |
| 249 | |
| 250 A field load from a term of type $\Dynamic$ is well-typed if the term is | |
| 251 well-typed. | |
| 252 | |
| 253 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 254 {e} | |
| 255 {\_} | |
| 256 {e'} | |
| 257 {\Dynamic} | |
| 258 } | |
| 259 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 260 {\eload{e}{m}} | |
| 261 {\_} | |
| 262 {\edload{e'}{m}} | |
| 263 {\Dynamic} | |
| 264 } | |
| 265 | |
| 266 A dynamic load is well typed so long as the term is well-typed. | |
|
vsm
2015/07/13 22:36:56
Ditto?
| |
| 267 | |
| 268 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 269 {e} | |
| 270 {\_} | |
| 271 {e'} | |
| 272 {\Dynamic} | |
| 273 } | |
| 274 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 275 {\edload{e}{m}} | |
| 276 {\_} | |
| 277 {\edload{e'}{m}} | |
| 278 {\Dynamic} | |
| 279 } | |
| 280 | |
| 281 An assignment expression is well-typed so long as the term is well-typed at a | |
| 282 type which is compatible with the type of the variable being assigned. | |
| 283 | |
| 284 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 285 {e} | |
| 286 {\opt{\tau}} | |
| 287 {e'} | |
| 288 {\sigma} \quad | |
| 289 \yieldsOk{\Phi, \Delta, \Gamma} | |
| 290 {x} | |
| 291 {\sigma} | |
| 292 {x} | |
| 293 {\sigma'} | |
| 294 } | |
| 295 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 296 {\eassign{x}{e}} | |
| 297 {\opt{\tau}} | |
| 298 {\eassign{x}{e'}} | |
| 299 {\sigma} | |
| 300 } | |
|
vsm
2015/07/13 22:36:56
This reads a little odd to me ... seems to suggest
Leaf
2015/07/14 22:39:49
The way it works here is a bit subtle, but I think
| |
| 301 | |
| 302 A field assignment is well-typed if the term being assigned is well-typed, the | |
| 303 field name is present in the type of $\ethis$, and the declared type of the | |
| 304 field is compatible with the type of the expression being assigned. | |
| 305 | |
| 306 \infrule{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 307 {e} | |
| 308 {\opt{\tau}} | |
| 309 {e'} | |
| 310 {\sigma} \quad\quad | |
| 311 \Gamma = \Gamma_\tau & \fieldLookup{\Phi}{\tau}{m}{\sigma'} \quad | |
| 312 \subtypeOf{\Phi, \Delta}{\sigma}{\sigma'} | |
| 313 } | |
| 314 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 315 {\eset{\ethis}{m}{e}} | |
| 316 {\opt{\tau}} | |
| 317 {\eset{\ethis}{m}{e}} | |
| 318 {\sigma} | |
| 319 } | |
| 320 | |
| 321 A throw expression is well-typed at any type. | |
| 322 | |
| 323 \axiom{\yieldsOk{\Phi, \Delta, \Gamma} | |
| 324 {\ethrow} | |
| 325 {\_} | |
| 326 {\ethrow} | |
| 327 {\sigma} | |
| 328 } | |
| 329 | |
| 330 A cast expression is well-typed so long as the term being cast is well-typed. | |
| 331 The synthesized type is the cast-to type. | |
| 332 | |
| 333 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\sigma} | |
| 334 } | |
| 335 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 336 {\eas{e}{\tau}} | |
| 337 {\_} | |
| 338 {\eas{e'}{\tau}} | |
| 339 {\tau} | |
| 340 } | |
| 341 | |
| 342 An instance check expression is well-typed if the term being checked is | |
| 343 well-typed. | |
| 344 | |
| 345 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\sigma} | |
| 346 } | |
| 347 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 348 {\eis{e}{\tau}} | |
| 349 {\_} | |
| 350 {\eis{e'}{\tau}} | |
| 351 {\Bool} | |
| 352 } | |
|
vsm
2015/07/13 22:36:56
Should \tau be required to be ground here and abov
Leaf
2015/07/14 22:39:49
Yes.
Leaf
2015/07/14 22:39:49
Done.
| |
| 353 | |
| 354 A check expression is well-typed so long as the term being checked is | |
| 355 well-typed. The synthesized type is the target type of the check. | |
| 356 | |
| 357 | |
| 358 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\sigma} | |
| 359 } | |
| 360 {\yieldsOk{\Phi, \Delta, \Gamma} | |
| 361 {\echeck{e}{\tau}} | |
| 362 {\_} | |
| 363 {\echeck{e'}{\tau}} | |
| 364 {\tau} | |
| 365 } | |
| 366 | |
| 367 \subsection*{Declaration typing: $\declOk[d]{\Phi, \Delta, \Gamma}{\mathit{vd}}{ \mathit{vd'}}{\Gamma'}$} | |
| 368 \hrulefill | |
| 369 | |
| 370 Variable declaration typing checks the well-formedness of the components, and | |
| 371 produces an output context $\Gamma'$ which contains the binding introduced by | |
| 372 the declaration. | |
| 373 | |
| 374 A simple variable declaration with a declared type is well-typed if the | |
| 375 initializer for the declaration is well-typed at the declared type. The output | |
| 376 context binds the variable at the declared type. | |
| 377 | |
| 378 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\tau}{e'}{\tau'} \quad | |
| 379 } | |
| 380 {\declOk[d]{\Phi, \Delta, \Gamma} | |
| 381 {\dvar{x:\tau}{e}} | |
| 382 {\dvar{x:\tau'}{e'}} | |
| 383 {\extends{\Gamma}{x}{\tau}} | |
| 384 } | |
| 385 | |
| 386 A simple variable declaration without a declared type is well-typed if the | |
| 387 initializer for the declaration is well-typed at any type. The output context | |
| 388 binds the variable at the synthesized type (a simple form of type inference). | |
| 389 | |
| 390 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\tau'} \quad | |
| 391 } | |
| 392 {\declOk[d]{\Phi, \Delta, \Gamma} | |
| 393 {\dvar{x:\_}{e}} | |
| 394 {\dvar{x:\tau'}{e'}} | |
| 395 {\extends{\Gamma}{x}{\tau'}} | |
| 396 } | |
| 397 | |
| 398 A function declaration is well-typed if the body of the function is well-typed | |
| 399 with the given return type, under the assumption that the function and its | |
| 400 parameters have their declared types. The function is assumed to have a | |
| 401 contravariant (precise) function type. The output context binds the function | |
| 402 variable only. | |
| 403 | |
| 404 \infrule{\tau_f = \Arrow[-]{\many{\tau_a}}{\tau_r} \quad | |
| 405 \Gamma' = \extends{\Gamma}{f}{\tau_f} \quad | |
| 406 \Gamma'' = \extends{\Gamma'}{\many{x}}{\many{\tau_a}} \\ | |
| 407 \stmtOk{\Phi, \Delta, \Gamma''}{s}{\tau_r}{s'}{\Gamma_0} | |
| 408 } | |
| 409 {\declOk[d]{\Phi, \Delta, \Gamma} | |
| 410 {\dfun{\tau_r}{f}{\many{x:\tau_a}}{s}} | |
| 411 {\dfun{\tau_r}{f}{\many{x:\tau_a}}{s'}} | |
| 412 {\Gamma'} | |
| 413 } | |
| 414 | |
| 415 \subsection*{Statement typing: $\stmtOk{\Phi, \Delta, \Gamma}{\mathit{s}}{\tau}{ \mathit{s'}}{\Gamma'}$} | |
| 416 \hrulefill | |
| 417 | |
| 418 The statement typing relation checks the well-formedness of statements and | |
| 419 produces an output context which reflects any additional variable bindings | |
| 420 introduced into scope by the statements. | |
| 421 | |
| 422 A variable declaration statement is well-typed if the variable declaration is | |
| 423 well-typed per the previous relation, with the corresponding output context. | |
| 424 | |
| 425 \infrule{\declOk[d]{\Phi, \Delta, \Gamma} | |
| 426 {\mathit{vd}} | |
| 427 {\mathit{vd'}} | |
| 428 {\Gamma'} | |
| 429 } | |
| 430 {\stmtOk{\Phi, \Delta, \Gamma} | |
| 431 {\mathit{vd}} | |
| 432 {\tau} | |
| 433 {\mathit{vd'}} | |
| 434 {\Gamma'} | |
| 435 } | |
| 436 | |
| 437 An expression statement is well-typed if the expression is well-typed at any | |
| 438 type per the expression typing relation. | |
| 439 | |
| 440 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\_}{e'}{\tau} | |
| 441 } | |
| 442 {\stmtOk{\Phi, \Delta, \Gamma}{e}{\tau}{e'}{\Gamma} | |
| 443 } | |
| 444 | |
| 445 A conditional statement is well-typed if the condition is well-typed as a | |
| 446 boolean, and the statements making up the two arms are well-typed. The output | |
| 447 context is unchanged. | |
| 448 | |
| 449 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\Bool}{e'}{\sigma} \quad | |
| 450 \stmtOk{\Phi, \Delta, \Gamma}{s_1}{\tau_r}{s_1'}{\Gamma_1} \quad | |
| 451 \stmtOk{\Phi, \Delta, \Gamma}{s_2}{\tau_r}{s_2'}{\Gamma_2} | |
| 452 } | |
| 453 {\stmtOk{\Phi, \Delta, \Gamma} | |
| 454 {\sifthenelse{e}{s_1}{s_2}} | |
| 455 {\tau_r} | |
| 456 {\sifthenelse{e'}{s_1'}{s_2'}} | |
| 457 {\Gamma} | |
| 458 } | |
| 459 | |
| 460 A return statement is well-typed if the expression being returned is well-typed | |
| 461 at the given return type. | |
| 462 | |
| 463 \infrule{\yieldsOk{\Phi, \Delta, \Gamma}{e}{\tau_r}{e'}{\tau} | |
| 464 } | |
| 465 {\stmtOk{\Phi, \Delta, \Gamma}{\sreturn{e}}{\tau_r}{\sreturn{e'}}{\Gamma } | |
| 466 } | |
| 467 | |
| 468 A sequence statement is well-typed if the first component is well-typed, and the | |
| 469 second component is well-typed with the output context of the first component as | |
| 470 its input context. The final output context is the output context of the second | |
| 471 component. | |
| 472 | |
| 473 \infrule{\stmtOk{\Phi, \Delta, \Gamma}{s_1}{\tau_r}{s_1'}{\Gamma'} \quad | |
| 474 \stmtOk{\Phi, \Delta, \Gamma'}{s_2}{\tau_r}{s_2'}{\Gamma''} | |
| 475 } | |
| 476 {\stmtOk{\Phi, \Delta, \Gamma}{s_1;s_2}{\tau_r}{s_1';s_2'}{\Gamma''} | |
| 477 } | |
| OLD | NEW |