Debian Codegraph @

doc/ref/spec.html

raw symbols SCIP
1 ---
2 layout: base
3 title: Specification
4 ---
5
6 <style>
7 /* Non-terminals */
8 i {
9 font-family: Arial, sans-serif;
10 font-style: italic;
11 color: #008
12 }
13
14 /* Value sets */
15 em {
16 font-family: Arial, sans-serif;
17 font-style: italic;
18 color: #800
19 }
20
21 code {
22 font-family: Courier New, monospace;
23 background-color: #efefef;
24 font-size: 15px;
25 }
26
27 div.desugar-rule {
28 font-size:75%;
29 }
30
31 div.desugar-rule-group {
32 padding: 3px 0;
33 }
34
35 div.sequent-rule {
36 margin:10px;
37 float:left;
38 font-size:75%;
39 }
40
41 div.rules {
42 overflow: auto;
43 width:100%
44 }
45 </style>
46
47 <div style="display:none">
48 \[
49 \newcommand{\assert}[1]{\texttt{assert }#1}
50 \newcommand{\array}[1]{[ #1 ]}
51 \newcommand{\assign}[2]{ #1\texttt{ = }#2}
52 \newcommand{\binary}[3]{ #1\texttt{ }#2\texttt{ }#3}
53 \newcommand{\error}[1]{\texttt{error }#1}
54 \newcommand{\false}{\texttt{false}}
55 \newcommand{\function}[2]{\texttt{function}\texttt{(} #1\texttt{)}{\ #2}}
56 \newcommand{\if}[3]{\texttt{if }#1\texttt{ then }#2\texttt{ else }#3}
57 \newcommand{\ifnoelse}[2]{\texttt{if }#1\texttt{ then }#2}
58 \newcommand{\import}[1]{\texttt{import }#1}
59 \newcommand{\importstr}[1]{\texttt{importstr }#1}
60 \newcommand{\importbin}[1]{\texttt{importbin }#1}
61 \newcommand{\index}[2]{#1\texttt{[}#2\texttt{]}}
62 \newcommand{\local}[2]{\texttt{local }#1\texttt{ ; }#2}
63 \newcommand{\null}{\texttt{null}}
64 \newcommand{\object}[1]{\{ #1 \}}
65 \newcommand{\objlocal}[1]{\texttt{local }#1}
66 \newcommand{\ocomp}[4]{\object{[#1]:#2\texttt{ for }#3\texttt{ in }#4}}
67 \newcommand{\self}{\texttt{self}}
68 \newcommand{\super}{\texttt{super}}
69 \newcommand{\true}{\texttt{true}}
70 \newcommand{\unary}[2]{\texttt{ }#1\texttt{ }#2}
71
72 \newcommand{\rule}[3]{\frac{#2}{#3}\textrm{(#1)}}
73 \]
74 </div>
75
76 <div class="hgroup">
77 <div class="hgroup-inline">
78 <div class="panel">
79 <h1 id="specification">Jsonnet Specification</h1>
80 </div>
81 <div style="clear: both"></div>
82 </div>
83 </div>
84
85 <div class="hgroup">
86 <div class="hgroup-inline">
87 <div class="panel">
88 <p>
89 This page is the authority on what Jsonnet programs should do. It defines Jsonnet lexing
90 and syntax. It describes which programs should be rejected statically (i.e. before
91 execution). Finally, it specifies the manner in which the program is executed, i.e. the
92 JSON that is output, or the runtime error if there is one.
93 </p>
94 <p>
95 The specification is intended to be terse, precise, and illuminate all the subtleties and
96 edge cases in order to allow fully-compatible language reimplementations and tools. The
97 specification employs some standard theoretical computer science techniques, namely <a
98 href="https://en.wikipedia.org/wiki/Type_system">type systems</a> and <a
99 href="https://en.wikipedia.org/wiki/Operational_semantics">big step operational
100 semantics</a>. If you just want to write Jsonnet code (not build a Jsonnet interpreter or
101 tool), you don't need to read this. You should read the <a
102 href="/learning/tutorial.html">tutorial</a> and <a href="/ref/language.html">reference</a> .
103 </p>
104 </div>
105 <div style="clear: both"></div>
106 </div>
107 </div>
108
109
110 <div class="hgroup">
111 <div class="hgroup-inline">
112 <div class="panel">
113 <h2 id="lexing">Lexing</h2>
114 </div>
115 <div style="clear: both"></div>
116 </div>
117 </div>
118
119 <div class="hgroup">
120 <div class="hgroup-inline">
121 <div class="panel">
122 <p>
123 A Jsonnet program is UTF-8 encoded text. The file is a sequence of tokens, separated by
124 optional whitespace and comments. Whitespace consists of space, tab, newline and carriage
125 return. Tokens are lexed greedily. Comments are either single line comments, beginning
126 with a <code>#</code> or a <code>//</code>, or block comments beginning with <code>/*</code>
127 and terminating at the first <code>*/</code> encountered within the comment.
128 </p>
129 <ul>
130 <li>
131 <p>
132 <i>id</i>: Matched by <tt>[_a-zA-Z][_a-zA-Z0-9]*</tt>.
133 </p>
134 <p>
135 Some identifiers are reserved as keywords, thus are not in the set <i>id</i>:
136 <code>assert</code> <code>else</code> <code>error</code> <code>false</code>
137 <code>for</code> <code>function</code> <code>if</code> <code>import</code>
138 <code>importstr</code> <code>importbin</code> <code>in</code> <code>local</code> <code>null</code>
139 <code>tailstrict</code> <code>then</code> <code>self</code> <code>super</code>
140 <code>true</code>.
141 </p>
142 </li>
143 <li>
144 <p>
145 <i>number</i>: As defined by <a href="https://json.org/">JSON</a> but without the leading
146 minus.
147 </p>
148 </li>
149 <li>
150 <p>
151 <i>string</i>: Which can have five quoting forms:
152 </p>
153 <ul>
154 <li>
155 Double-quoted, beginning with <code>"</code> and ending with the first subsequent
156 non-quoted <code>"</code>
157 </li>
158 <li>
159 Single-quoted, beginning with <code>'</code> and ending with the first subsequent
160 non-quoted <code>'</code>
161 </li>
162 <li>
163 Double-quoted verbatim, beginning with <code>@"</code> and ending with the first
164 subsequent non-quoted <code>"</code>
165 </li>
166 <li>
167 Single-quoted verbatim, beginning with <code>@'</code> and ending with the first
168 subsequent non-quoted <code>'</code>
169 </li>
170 <li>
171 Text block, beginning with <code>|||</code>, followed by optional whitespace and a
172 new-line. The next non-empty line must be prefixed with some non-zero length
173 whitespace <i>W</i>. The block ends at the first subsequent line that is non-empty
174 and does not begin with <i>W</i>, and it is an error if this line does not contain
175 some optional whitespace followed by <code>|||</code>. The content of the string is
176 the concatenation of all the lines between the two <code>|||</code>, which either
177 begin with <i>W</i> (in which case that prefix is stripped) or they are empty lines
178 (in which case they remain as empty lines). The line ending style in the file is
179 preserved in the string. This form cannot be used in <code>import</code> statements.
180 </li>
181 </ul>
182 <p>
183 Double- and single-quoted strings are allowed to span multiple lines, in which case
184 whatever dos/unix end-of-line character your editor inserts will be put in the string.
185 They both understand the following escape characters: <code>"'\/bfnrt</code> which have
186 their standard meanings, as well as <code>\uXXXX</code> for hexadecimal unicode escapes.
187 </p>
188 <p>
189 Verbatim strings eschew all of the normal string escaping, including hexadecimal unicode
190 escapes. Every character in a verbatim string is processed literally, with the
191 exception of doubled end-quotes. Within a verbatim single-quoted string,
192 <code>''</code> is processed as <code>'</code>, and a verbatim double-quoted string,
193 <code>""</code> is processed as <code>"</code>.
194 </p>
195 <p>
196 In the rest of this specification, the string is assumed to be canonicalized into a
197 sequence of unicode codepoints with no record of the original quoting form as well and
198 any escape characters removed.
199 </p>
200 </li>
201 <li>
202 <p>
203 <i>symbol</i>: The following single-character symbols:
204 </p>
205 <p><code>{}[],.();</code></p>
206 </li>
207 <li>
208 <p>
209 <i>operator</i>: A sequence of at least one of the following single-character symbols:
210 <code>!$:~+-&amp;|^=&lt;&gt;*/%</code>.
211 </p>
212 <p>
213 Additionally it is subject to the following rules, which may cause the lexing to terminate with a shorter
214 token:
215 </p>
216 <ul>
217 <li>
218 The sequence <code>//</code> is not allowed in an operator.
219 </li>
220 <li>
221 The sequence <code>/*</code> is not allowed in an operator.
222 </li>
223 <li>
224 The sequence <code>|||</code> is not allowed in an operator.
225 </li>
226 <li>
227 If the sequence has more than one character, it is not allowed to end in any of
228 <code>+</code>, <code>-</code>, <code>~</code>, <code>!</code>, <code>$</code>.
229 </li>
230 </ul>
231 </li>
232 </ul>
233 </div>
234 <div style="clear: both"></div>
235 </div>
236 </div>
237
238
239 <div class="hgroup">
240 <div class="hgroup-inline">
241 <div class="panel">
242 <h2 id="abstract_syntax">Abstract Syntax</h2>
243 </div>
244 <div style="clear: both"></div>
245 </div>
246 </div>
247
248 <div class="hgroup">
249 <div class="hgroup-inline">
250 <div class="panel">
251 <p>
252 The notation used here is as follows: { } denotes zero or more repetitions of a sequence of
253 tokens, and [ ] represents an optional sequence of tokens. This is not to be confused with
254 <code>{ }</code> and <code>[ ]</code> which represent tokens in Jsonnet itself.
255 </p>
256
257 <p>
258 Note that although the lexer will generate tokens for a wide range of operators, only a
259 finite set are currently parseable, the rest being reserved for possible future use.
260 </p>
261 </div>
262 <div style="clear: both"></div>
263 </div>
264 </div>
265
266 <div class="inverse hgroup">
267 <div class="hgroup-inline">
268 <div class="panel wide">
269 <table>
270 <tr>
271 <td><i>expr ∈ Expr</i></td>
272 <td>::=</td>
273 <td>
274 <code>null</code> |
275 <code>true</code> |
276 <code>false</code> |
277 <code>self</code> |
278 <code>$</code> |
279 <i>string</i> |
280 <i>number</i>
281 </td>
282 </tr>
283
284 <!-- object -->
285 <tr>
286 <td></td>
287 <td> | </td>
288 <td>
289 <code>{</code>
290 <i>objinside</i>
291 <code>}</code>
292 </td>
293 </tr>
294
295 <!-- array -->
296 <tr>
297 <td></td>
298 <td>|</td>
299 <td>
300 <code>[</code>
301 [ <i>expr</i> { <code>,</code> <i>expr</i> } [ <code>,</code> ] ]
302 <code>]</code>
303 </td>
304 </tr>
305
306 <!-- array comprehension -->
307 <tr>
308 <td></td>
309 <td> | </td>
310 <td>
311 <code>[</code>
312 <i>expr</i>
313 [ <code>,</code> ]
314 <i>forspec</i> <i>compspec</i>
315 <code>]</code>
316 </td>
317 </tr>
318
319 <!-- object index (id) -->
320 <tr>
321 <td></td>
322 <td> | </td>
323 <td>
324 <i>expr</i>
325 <code>.</code>
326 <i>id</i>
327 </td>
328 </tr>
329
330 <!-- object index (general) -->
331 <tr>
332 <td></td>
333 <td> | </td>
334 <td>
335 <i>expr</i>
336 <code>[</code>
337 [ <i>expr</i> ]
338 [ <code>:</code> [ <i> expr</i> ]
339 [ <code>:</code> [ <i>expr</i> ] ] ]
340 <code>]</code>
341 </td>
342 </tr>
343
344 <!-- super index (id) -->
345 <tr>
346 <td></td>
347 <td> | </td>
348 <td>
349 <code>super</code>
350 <code>.</code>
351 <i>id</i>
352 </td>
353 </tr>
354
355 <!-- super index (general) -->
356 <tr>
357 <td></td>
358 <td> | </td>
359 <td>
360 <code>super</code>
361 <code>[</code>
362 <i>expr</i>
363 <code>]</code>
364 </td>
365 </tr>
366
367 <!-- apply -->
368 <tr>
369 <td></td>
370 <td> | </td>
371 <td>
372 <i>expr</i>
373 <code>(</code>
374 [ <i>args</i> ]
375 <code>)</code>
376 </td>
377 </tr>
378
379 <!-- var -->
380 <tr>
381 <td></td>
382 <td> | </td>
383 <td>
384 <i>id</i>
385 </td>
386 </tr>
387
388 <!-- local expression -->
389 <tr>
390 <td></td>
391 <td> | </td>
392 <td>
393 <code>local</code>
394 <i>bind</i>
395 {
396 <code>,</code>
397 <i>bind</i>
398 }
399 <code>;</code>
400 <i>expr</i>
401 </td>
402 </tr>
403
404 <!-- conditional -->
405 <tr>
406 <td></td>
407 <td> | </td>
408 <td>
409 <code>if</code>
410 <i>expr</i>
411 <code>then</code>
412 <i>expr</i>
413 [ <code>else</code>
414 <i>expr</i> ]
415 </td>
416 </tr>
417
418 <!-- binary -->
419 <tr>
420 <td></td>
421 <td> | </td>
422 <td>
423 <i>expr</i>
424 <i>binaryop</i>
425 <i>expr</i>
426 </td>
427 </tr>
428
429 <!-- unary -->
430 <tr>
431 <td></td>
432 <td> | </td>
433 <td>
434 <i>unaryop</i>
435 <i>expr</i>
436 </td>
437 </tr>
438
439 <!-- object apply -->
440 <tr>
441 <td></td>
442 <td> | </td>
443 <td>
444 <i>expr</i>
445 <code>{</code>
446 <i>objinside</i>
447 <code>}</code>
448 </td>
449 </tr>
450
451 <!-- function -->
452 <tr>
453 <td></td>
454 <td> | </td>
455 <td>
456 <code>function</code>
457 <code>(</code>
458 [ <i>params</i> ]
459 <code>)</code>
460 <i>expr</i>
461 </td>
462 </tr>
463
464 <!-- assert -->
465 <tr>
466 <td></td>
467 <td> | </td>
468 <td>
469 <i>assert</i>
470 <code>;</code>
471 <i>expr</i>
472 </td>
473 </tr>
474
475 <!-- import -->
476 <tr>
477 <td></td>
478 <td> | </td>
479 <td>
480 <code>import</code>
481 <i>string</i>
482 </td>
483 </tr>
484
485 <!-- importstr -->
486 <tr>
487 <td></td>
488 <td> | </td>
489 <td>
490 <code>importstr</code>
491 <i>string</i>
492 </td>
493 </tr>
494
495 <!-- importbin -->
496 <tr>
497 <td></td>
498 <td> | </td>
499 <td>
500 <code>importbin</code>
501 <i>string</i>
502 </td>
503 </tr>
504
505 <!-- error -->
506 <tr>
507 <td></td>
508 <td> | </td>
509 <td>
510 <code>error</code>
511 <i>expr</i>
512 </td>
513 </tr>
514
515 <!-- super in e -->
516 <tr>
517 <td></td>
518 <td> | </td>
519 <td>
520 <i>expr</i> <code>in</code> <code>super</code>
521 </td>
522 </tr>
523 </table>
524
525
526 <p></p>
527
528 <!-- AUX STUFF -->
529
530 <table>
531 <tr>
532 <td><i>objinside</i></td>
533 <td>::=</td>
534 <td>
535 <!-- object -->
536 <i>member</i> { <code>,</code> <i>member</i> } [ <code>,</code> ]
537 </td>
538 </tr>
539
540 <!-- object comprehension -->
541 <tr>
542 <td></td>
543 <td> | </td>
544 <td>
545 { <i>objlocal</i> <code>,</code> }
546 <code>[</code>
547 <i>expr</i>
548 <code>]</code>
549 <code>:</code>
550 <i>expr</i>
551 [ { <code>,</code> <i>objlocal</i> } ] [ <code>,</code> ]
552 <i>forspec</i> <i>compspec</i>
553 </td>
554 </tr>
555
556 <!-- member -->
557 <tr>
558 <td><i>member</i></td>
559 <td>::=</td>
560 <td>
561 <i>objlocal</i> | <i>assert</i> | <i>field</i>
562 </td>
563 </tr>
564
565 <!-- field -->
566 <tr>
567 <td><i>field ∈ Field</i></td>
568 <td>::=</td>
569 <td>
570 <i>fieldname</i>
571 [ <code>+</code> ] <i>h</i>
572 <i>expr</i>
573 </td>
574 </tr>
575
576 <!-- method -->
577 <tr>
578 <td></td>
579 <td> | </td>
580 <td>
581 <i>fieldname</i>
582 <code>(</code>
583 [ <i>params</i> ]
584 <code>)</code>
585 <i>h</i>
586 <i>expr</i>
587 </td>
588 </tr>
589
590 <!-- colons -->
591 <tr>
592 <td><i>h ∈ Hidden</i></td>
593 <td>::=</td>
594 <td>
595 <code>:</code> | <code>::</code> | <code>:::</code>
596 </td>
597 </tr>
598
599 <!-- obj local -->
600 <tr>
601 <td><i>objlocal</i></td>
602 <td>::=</td>
603 <td>
604 <code>local</code> <i>bind</i>
605 </td>
606 </tr>
607
608 <!-- compspec (object comps) -->
609 <tr>
610 <td><i>compspec ∈ CompSpec</i></td>
611 <td>::=</td>
612 <td>
613 { <i>forspec</i> | <i>ifspec</i> }
614 </td>
615 </tr>
616
617 <!-- for spec (object comps) -->
618 <tr>
619 <td><i>forspec</i></td>
620 <td>::=</td>
621 <td>
622 <code>for</code>
623 <i>id</i>
624 <code>in</code>
625 <i>expr</i>
626 </td>
627 </tr>
628
629 <!-- if spec (object comps) -->
630 <tr>
631 <td><i>ifspec</i></td>
632 <td>::=</td>
633 <td>
634 <code>if</code>
635 <i>expr</i>
636 </td>
637 </tr>
638
639 <!-- fieldname -->
640 <tr>
641 <td><i>fieldname</i></td>
642 <td>::=</td>
643 <td>
644 <i>id</i> |
645 <i>string</i> |
646 <code>[</code>
647 <i>expr</i>
648 <code>]</code>
649 </td>
650 </tr>
651 </table>
652
653 <p></p>
654
655 <!-- obj assert -->
656 <table>
657 <tr>
658 <td><i>assert</i></td>
659 <td>::=</td>
660 <td>
661 <code>assert</code> <i>expr</i> [ <code>:</code> <i>expr</i> ]
662 </td>
663 </tr>
664 </table>
665
666 <!-- bind -->
667 <table>
668 <tr>
669 <td><i>bind ∈ Bind</i></td>
670 <td>::=</td>
671 <td>
672 <i>id</i>
673 <code>=</code>
674 <i>expr</i>
675 </td>
676 </tr>
677 <tr>
678 <td></td>
679 <td> | </td>
680 <td>
681 <i>id</i>
682 <code>(</code>
683 [ <i>params</i> ]
684 <code>)</code>
685 <code>=</code>
686 <i>expr</i>
687 </td>
688 </tr>
689 </table>
690
691 <p></p>
692
693 <!-- args -->
694 <table>
695 <tr>
696 <td><i>args</i></td>
697 <td>::=</td>
698 <td>
699 <i>expr</i> { <code>,</code> <i>expr</i> } { <code>,</code> <i>id</i> <code>=</code>
700 <i>expr</i> } [ <code>,</code> ]
701 </td>
702 </tr>
703
704 <tr>
705 <td></td>
706 <td>|</td>
707 <td>
708 <i>id</i> <code>=</code> <i>expr</i> { <code>,</code> <i>id</i> <code>=</code>
709 <i>expr</i> } [ <code>,</code> ]
710 </td>
711 </tr>
712 </table>
713
714 <p></p>
715
716 <!-- params -->
717 <table>
718 <tr>
719 <td><i>params</i></td>
720 <td>::=</td>
721 <td>
722 <i>param</i> { <code>,</code> <i>param</i> } [ <code>,</code> ]
723 </td>
724 </tr>
725 </table>
726
727
728 <!-- param -->
729 <table>
730 <tr>
731 <td><i>param</i></td>
732 <td>::=</td>
733 <td>
734 <i>id</i> [ <code>=</code> <i>expr</i> ]
735 </td>
736 </tr>
737 </table>
738
739
740 <p></p>
741
742 <!-- binaryop -->
743 <table>
744 <tr>
745 <td><i>binaryop</i></td>
746 <td>::=</td>
747 <td>
748 <code>*</code> |
749 <code>/</code> |
750 <code>%</code> |
751 <code>+</code> |
752 <code>-</code> |
753 <code>&lt;&lt;</code> |
754 <code>&gt;&gt;</code> |
755 <code>&lt;</code> |
756 <code>&lt;=</code> |
757 <code>&gt;</code> |
758 <code>&gt;=</code> |
759 <code>==</code> |
760 <code>!=</code> |
761 <code>in</code> |
762 <code>&amp;</code> |
763 <code>^</code> |
764 <code>|</code> |
765 <code>&amp;&amp;</code> |
766 <code>||</code>
767 </td>
768 </tr>
769
770 <!-- unaryop -->
771 <tr>
772 <td><i>unaryop</i></td>
773 <td>::=</td>
774 <td> <code>-</code> | <code>+</code> | <code>!</code> | <code>~</code> </td>
775 </tr>
776 </table>
777
778 </div>
779 <div style="clear: both"></div>
780 </div>
781 </div>
782
783
784 <div class="hgroup">
785 <div class="hgroup-inline">
786 <div class="panel">
787 <h2 id="associativity_precedence">Associativity and Operator Precedence</h2>
788 </div>
789 <div style="clear: both"></div>
790 </div>
791 </div>
792
793 <div class="hgroup">
794 <div class="hgroup-inline">
795 <div class="panel">
796 <p>
797 The abstract syntax by itself cannot unambiguously parse a sequence of tokens. Ambiguities
798 are resolved according to the following rules, which can also be overridden by adding
799 parenthesis symbols <code>()</code>.
800 </p>
801
802 <p>
803 Everything is left associative. In the case of <code>assert</code>, <code>error</code>,
804 <code>function</code>, <code>if</code>, <code>import</code>, <code>importstr</code>, <code>importbin</code>, and
805 <code>local</code>, ambiguity is resolved by consuming as many tokens as possible on the
806 right hand side. For example the parentheses are redundant in <code>local x = 1; (x +
807 x)</code>. All remaining ambiguities are resolved according to the following decreasing
808 order of precedence:
809 </p>
810
811 <ol>
812 <li><code>e(...)</code> <code>e[...]</code> <code>e.f</code>
813 &nbsp;&nbsp;(application and indexing)</li>
814 <li><code>+</code> <code>-</code> <code>!</code> <code>~</code>
815 &nbsp;&nbsp;(the unary operators)</li>
816 <li><code>*</code> <code>/</code> <code>%</code>
817 &nbsp;&nbsp;(these, and the remainder below, are binary operators)</li>
818 <li><code>+</code> <code>-</code></li>
819 <li><code>&lt;&lt;</code> <code>&gt;&gt;</code></li>
820 <li>
821 <code>&lt;</code> <code>&gt;</code> <code>&lt;=</code> <code>&gt;=</code> <code>in</code>
822 </li>
823 <li><code>==</code> <code>!=</code></li>
824 <li><code>&amp;</code></li>
825 <li><code>^</code></li>
826 <li><code>|</code></li>
827 <li><code>&amp;&amp;</code></li>
828 <li><code>||</code></li>
829 </ol>
830 </div>
831 <div style="clear: both"></div>
832 </div>
833 </div>
834
835
836 <div class="hgroup">
837 <div class="hgroup-inline">
838 <div class="panel">
839 <h2 id="core">Core Language Subset</h2>
840 </div>
841 <div style="clear: both"></div>
842 </div>
843 </div>
844
845 <div class="hgroup">
846 <div class="hgroup-inline">
847 <div class="panel">
848 <p>
849 To make the specification of Jsonnet as simple as possible, many of the language features
850 are represented as syntax sugar. Below is defined the core syntax and the desugaring
851 function from the abstract syntax to the core syntax. Both the static checking rules and
852 the operational semantics are defined at the level of the core language, so it is possible
853 to desugar immediately after parsing.
854 </p>
855 </div>
856 <div style="clear: both"></div>
857 </div>
858 </div>
859
860
861 <div class="hgroup">
862 <div class="hgroup-inline">
863 <div class="panel">
864 <h3 id="core_syntax">Core Syntax</h3>
865 </div>
866 <div style="clear: both"></div>
867 </div>
868 </div>
869
870 <div class="hgroup">
871 <div class="hgroup-inline">
872 <div class="panel">
873 <p>
874 The core language has the following simplifications:
875 </p>
876 <ul>
877 <li>
878 The set of identifiers now includes <code>$</code>, which is no-longer a special keyword.
879 </li>
880 <li>
881 The following binary operators are removed: <code>!=</code> <code>==</code> <code>%</code>
882 <code>in</code>
883 </li>
884 <li>Array slices <code>[::]</code> are removed.</li>
885 <li>
886 Array and object comprehensions are replaced with a simple object comprehension construct.
887 </li>
888 <li>Expression-level asserts are removed.</li>
889 <li>Object-level level assert messages are removed.</li>
890 <li>
891 Object-level level assert values are ignored, but their evaluation may still raise an
892 error.
893 </li>
894 <li>Object methods and local functions are removed.</li>
895 <li>Object-level locals are removed.</li>
896 <li>Object field name definitions can only be expressions.</li>
897 <li>The <code>+:</code>, <code>+::</code>, and <code>+:::</code> sugars are removed.</li>
898 <li>Field lookup is only possible through <code>e[e]</code>.</li>
899 <li>All conditionals must have an else branch.</li>
900 <li>The keyword <code>super</code> can exist on its own.</li>
901 </ul>
902 <p>
903 Commas are no-longer part of this abstract syntax but we may still write them in our
904 notation to make the presentation more clear.
905 </p>
906 <p>
907 Also removed in the core language are <code>import</code>, <code>importstr</code>, and <code>importbin</code>. The
908 semantics of these constructs is that they are replaced with either the contents of the
909 file, or an error construct if importing failed (e.g. due to I/O errors). In the first
910 case, the file is parsed, desugared, and subject to static checking before it can be
911 substituted. In the case of <code>importstr</code>, the file is substituted in the form of a string, so it
912 merely needs to contain valid UTF-8. For <code>importbin</code>, the file is substituted as an array of integer numbers between 0 and 255 inclusive.
913 </p>
914 <p>
915 A given Jsonnet file can be recursively imported via <code>import</code>. Thus, the
916 implementation loads files lazily (i.e. during execution) as opposed to via static
917 desugaring. The imported Jsonnet file is parsed and statically checked in isolation.
918 Therefore, the behavior of the import is not affected by the environment into which it is
919 imported. The files are cached by filename, so that even if the file changes on disk during
920 Jsonnet execution, referential transparency is maintained.
921 </p>
922 <table>
923 <tr>
924 <td><i>e ∈ Core</i></td>
925 <td>::=</td>
926 <td>
927 <code>null</code> |
928 <code>true</code> |
929 <code>false</code> |
930 <code>self</code> |
931 <code>super</code> |
932 <i>string</i> |
933 <i>number</i>
934 </td>
935 </tr>
936
937 <!-- core objects -->
938 <tr>
939 <td></td>
940 <td> | </td>
941 <td>
942 <code>{</code>
943 {
944 <code>assert</code> <i>e</i>
945 }
946 {
947 <code>[</code> <i>e</i> <code>]</code> <i>h</i> <i>e</i>
948 }
949 <code>}</code>
950 </td>
951 </tr>
952
953 <!-- core object comprehension -->
954 <tr>
955 <td></td>
956 <td> | </td>
957 <td>
958 <code>{</code>
959 <code>[</code> <i>e</i> <code>]</code> <code>:</code> <i>e</i>
960 <code>for</code> <i>id</i> <code>in</code> <i>e</i>
961 <code>}</code>
962 </td>
963 </tr>
964
965 <!-- core array -->
966 <tr>
967 <td></td>
968 <td> | </td>
969 <td>
970 <code>[</code>
971 { <i>e</i> }
972 <code>]</code>
973 </td>
974 </tr>
975
976 <!-- core index -->
977 <tr>
978 <td></td>
979 <td> | </td>
980 <td>
981 <i>e</i>
982 <code>[</code>
983 <i>e</i>
984 <code>]</code>
985 </td>
986 </tr>
987
988 <!-- core apply -->
989 <tr>
990 <td></td>
991 <td> | </td>
992 <td>
993 <i>e</i>
994 <code>(</code>
995 { <i>e</i> }
996 { <i>id</i> <code>=</code> <i>e</i> }
997 <code>)</code>
998 </td>
999 </tr>
1000
1001 <!-- core var -->
1002 <tr>
1003 <td></td>
1004 <td> | </td>
1005 <td>
1006 <i>id</i>
1007 </td>
1008 </tr>
1009
1010 <!-- core local -->
1011 <tr>
1012 <td></td>
1013 <td> | </td>
1014 <td>
1015 <code>local</code>
1016 <i>id</i> <code>=</code> <i>e</i>
1017 {
1018 <i>id</i> <code>=</code> <i>e</i>
1019 }
1020 <code>;</code>
1021 <i>e</i>
1022 </td>
1023 </tr>
1024
1025 <!-- core conditional -->
1026 <tr>
1027 <td></td>
1028 <td> | </td>
1029 <td>
1030 <code>if</code>
1031 <i>e</i>
1032 <code>then</code>
1033 <i>e</i>
1034 <code>else</code>
1035 <i>e</i>
1036 </td>
1037 </tr>
1038
1039 <!-- core unary op -->
1040 <tr>
1041 <td></td>
1042 <td> | </td>
1043 <td>
1044 <i>e</i>
1045 <i>binaryop</i>
1046 <i>e</i>
1047 </td>
1048 </tr>
1049
1050 <!-- core binary op -->
1051 <tr>
1052 <td></td>
1053 <td> | </td>
1054 <td>
1055 <i>unaryop</i>
1056 <i>e</i>
1057 </td>
1058 </tr>
1059
1060 <!-- core closure -->
1061 <tr>
1062 <td></td>
1063 <td> | </td>
1064 <td>
1065 <code>function</code>
1066 <code>(</code>
1067 { <i>id</i> <code>=</code> <i>e</i> }
1068 <code>)</code>
1069 <i>e</i>
1070 </td>
1071 </tr>
1072
1073 <!-- core error -->
1074 <tr>
1075 <td></td>
1076 <td> | </td>
1077 <td>
1078 <code>error</code>
1079 <i>e</i>
1080 </td>
1081 </tr>
1082 </table>
1083 </div>
1084 <div style="clear: both"></div>
1085 </div>
1086 </div>
1087
1088
1089 <div class="hgroup">
1090 <div class="hgroup-inline">
1091 <div class="panel">
1092 <h3 id="desugaring">Desugaring</h3>
1093 </div>
1094 <div style="clear: both"></div>
1095 </div>
1096 </div>
1097
1098 <div class="hgroup">
1099 <div class="hgroup-inline">
1100 <div class="panel">
1101 <p>
1102 Desugaring removes constructs that are not in the core language by replacing them with
1103 constructs that are. It is defined via the following functions, which proceed by
1104 syntax-directed recursion. If a function is not defined on a construct then it simply
1105 recurses into the sub-expressions of that construct. Note that we import the standard
1106 library at the top of every file, and some of the desugarings call functions defined in the
1107 standard library. Their behavior is specified by implementation. However not all standard
1108 library functions are written in Jsonnet. The ones that are built into the interpreter
1109 (e.g. reflection) will be given special operational semantics rules with the rest of the
1110 core language constructs.
1111 </p>
1112 </div>
1113 <div style="clear: both"></div>
1114 </div>
1115 </div>
1116
1117 <div class="inverse hgroup">
1118 <div class="hgroup-inline">
1119 <div class="panel wide">
1120 <div class="desugar-rule-group">
1121 <p>
1122 <i>desugar</i>: Expr → Core. This desugars a Jsonnet file. Let \(e_{std}\) be the parsed
1123 content of <a href="https://github.com/google/jsonnet/blob/master/stdlib/std.jsonnet">
1124 <tt>std.jsonnet</tt></a>.
1125 </p>
1126 <div class="desugar-rule">
1127 \[
1128 desugar(e) = desugar_{expr}(\local{\texttt{std} = e_{std}}{e}, false)
1129 \]
1130 </div>
1131 </div>
1132 <div class="desugar-rule-group">
1133 <p>
1134 <i>desugar<sub>expr</sub></i>: (Expr × Boolean) → Core: This desugars an expression. The
1135 second parameter of the function tracks whether we are within an object.
1136 </p>
1137 <div class="desugar-rule">
1138 \[
1139 desugar_{expr}(\{
1140 \objlocal{bind_1} \ldots \objlocal{bind_n},
1141 assert_1 \ldots assert_m, field_1 \ldots field_p
1142 \}, b) = \\
1143 \hspace{10mm}
1144 \textrm{let }binds = \left\{\begin{array}{ll}
1145 bind_1 \ldots bind_n &amp; \textrm{if }b \\
1146 bind_1 \ldots bind_n, \objlocal{$ = \self} &amp; \textrm{otherwise} \\
1147 \end{array}\right. \\
1148 \hspace{10mm}
1149 \textrm{let } obj = \{ \\
1150 \hspace{20mm} desugar_{assert}(assert_1, binds)
1151 \ldots desugar_{assert}(assert_m, binds), \\
1152 \hspace{20mm} desugar_{field}(field_1, binds)
1153 \ldots desugar_{field}(field_p, binds, b) \\
1154 \hspace{10mm} \} \\
1155 \hspace{10mm} \textrm{in } \left\{\begin{array}{ll}
1156 \local{\texttt{\$outerself} = \self, \texttt{\$outersuper} = \super} {obj}
1157 &amp; \textrm{if }b \\
1158 obj &amp; \textrm{otherwise} \\
1159 \end{array}\right. \\
1160 \]
1161 </div>
1162 <div class="desugar-rule">
1163 \[
1164 desugar_{expr}(\object{
1165 \objlocal{bind_1} \ldots \objlocal{bind_m},
1166 [e_f] : e_{body},
1167 \objlocal{bind_m+1} \ldots \objlocal{bind_n}
1168 forspec\ compspec
1169 }, b) = \\
1170
1171 \hspace{10mm} \textrm{Let } arr \textrm{ fresh and } x_1 \ldots x_n
1172 \textrm{ be the sequence of variables defined in }forspec\ compspec \\
1173
1174 \hspace{10mm} \object{ \\
1175 \hspace{20mm} [desugar_{expr}(\local{x_1=arr[0] \ldots x_n=arr[n-1]}{e_f}, b)]: \\
1176 \hspace{30mm} desugar_{expr}(
1177 \local{x_1=arr[0] \ldots x_n=arr[n-1]}{
1178 \local{bind_1 \ldots bind_n}{e_{body}}
1179 }, true) \\
1180 \hspace{20mm} \textrm{ for } arr \textrm{ in }
1181 desugar_{expr}([ [x_1 \ldots x_n] forspec\ compspec, b): \\
1182 \hspace{10mm}}
1183 \]
1184 </div>
1185 <div class="desugar-rule">
1186 \[
1187 desugar_{expr}([e\ forspec\ compspec], b) = desugar_{arrcomp}(e, forspec\ compspec, b)
1188 \]
1189 </div>
1190 <div class="desugar-rule">
1191 \[
1192 desugar_{expr}(\local {bind_1 \ldots bind_n} e, b) =
1193 \local {desugar_{bind}(bind_1, b) \ldots
1194 desugar_{bind}(bind_n, b)} {desugar_{expr}(e, b)}
1195 \]
1196 </div>
1197 <div class="desugar-rule">
1198 \[
1199 desugar_{expr}(e \{ objinside \}, b) = desugar_{expr}(e + \{ objinside \}, b)
1200 \]
1201 </div>
1202 <div class="desugar-rule">
1203 \[
1204 desugar_{expr}(\function{p_1 \ldots p_n}e, b) = \function{desugar_{param}(p_1, b)\ldots desugar_{param}(p_n, b)} desugar_{expr}(e, b)
1205 \]
1206 </div>
1207 <div class="desugar-rule">
1208 \[
1209 desugar_{expr}(\assert e ; e', b) =
1210 desugar_{expr}(\assert e : \texttt{"Assertion failed"} ; e', b)
1211 \]
1212 </div>
1213 <div class="desugar-rule">
1214 \[
1215 desugar_{expr}(\assert e : e' ; e'', b) = desugar_{expr}(\if {e} {e''} {\error{e'}}, b)
1216 \]
1217 </div>
1218
1219 <!-- 1 slice default -->
1220
1221 <div class="desugar-rule">
1222 \[
1223 desugar_{expr}(e[e':e'':], b) = desugar_{expr}(e[e':e'':\null], b)
1224 \]
1225 </div>
1226
1227 <div class="desugar-rule">
1228 \[
1229 desugar_{expr}(e[e':e''], b) = desugar_{expr}(e[e':e'':\null], b)
1230 \]
1231 </div>
1232
1233 <div class="desugar-rule">
1234 \[
1235 desugar_{expr}(e[e'::e'''], b) = desugar_{expr}(e[e':\null:e'''], b)
1236 \]
1237 </div>
1238
1239 <div class="desugar-rule">
1240 \[
1241 desugar_{expr}(e[:e'':e'''], b) = desugar_{expr}(e[\null:e'':e'''], b)
1242 \]
1243 </div>
1244
1245 <!-- 2 slice defaults -->
1246
1247 <div class="desugar-rule">
1248 \[
1249 desugar_{expr}(e[e':], b) = desugar_{expr}(e[e':\null:\null], b)
1250 \]
1251 </div>
1252
1253 <div class="desugar-rule">
1254 \[
1255 desugar_{expr}(e[:e'':], b) = desugar_{expr}(e[\null:e'':\null], b)
1256 \]
1257 </div>
1258
1259 <div class="desugar-rule">
1260 \[
1261 desugar_{expr}(e[:e''], b) = desugar_{expr}(e[\null:e'':\null], b)
1262 \]
1263 </div>
1264
1265 <div class="desugar-rule">
1266 \[
1267 desugar_{expr}(e[::e'''], b) = desugar_{expr}(e[\null:\null:e'''], b)
1268 \]
1269 </div>
1270
1271 <!-- 3 slice defaults -->
1272
1273 <div class="desugar-rule">
1274 \[
1275 desugar_{expr}(e[::], b) = desugar_{expr}(e[\null:\null:\null], b)
1276 \]
1277 </div>
1278
1279 <div class="desugar-rule">
1280 \[
1281 desugar_{expr}(e[:], b) = desugar_{expr}(e[\null:\null:\null], b)
1282 \]
1283 </div>
1284
1285 <!-- slice -->
1286
1287 <div class="desugar-rule">
1288 \[
1289 desugar_{expr}(e[e':e'':e'''], b) =
1290 desugar_{expr}(\texttt{std.slice}(e, e', e'', e'''), b)
1291 \]
1292 </div>
1293
1294 <div class="desugar-rule">
1295 \[
1296 desugar_{expr}(\ifnoelse e e'), b) =
1297 \if {desugar_{expr}(e, b)} {desugar_{expr}(e', b)} {\null}
1298 \]
1299 </div>
1300
1301 <div class="desugar-rule">
1302 \[
1303 desugar_{expr}(e.id, b) = desugar_{expr}(e, b)[\texttt{"}id\texttt{"}]
1304 \]
1305 </div>
1306
1307 <div class="desugar-rule">
1308 \[
1309 desugar_{expr}(\super.id, b) = \super[\texttt{"}id\texttt{"}]
1310 \]
1311 </div>
1312
1313 <div class="desugar-rule">
1314 \[
1315 desugar_{expr}(e \mathop{\textrm{!=}} e', b) = desugar_{expr}(!(e \mathop{==} e'), b)
1316 \]
1317 </div>
1318
1319 <div class="desugar-rule">
1320 \[
1321 desugar_{expr}(e \mathop{==} e', b) = desugar_{expr}(\texttt{std.equals}(e, e'), b)
1322 \]
1323 </div>
1324
1325 <div class="desugar-rule">
1326 \[
1327 desugar_{expr}(e \mathop{\%} e', b) = desugar_{expr}(\texttt{std.mod}(e, e'), b)
1328 \]
1329 </div>
1330
1331 <div class="desugar-rule">
1332 \[
1333 desugar_{expr}(e \mathop{\texttt{in}} e', b) =
1334 desugar_{expr}(\texttt{std.objectHasEx}(e', e, \texttt{true}), b)
1335 \]
1336 </div>
1337
1338 <div class="desugar-rule">
1339 \[
1340 desugar_{expr}(e \mathop{\texttt{in}} \texttt{super}, b) =
1341 desugar_{expr}(\texttt{std.objectHasEx}(\texttt{super}, e, \texttt{true}), b)
1342 \]
1343 </div>
1344 </div>
1345 <div class="desugar-rule-group">
1346 <p>
1347 <i>desugar<sub>assert</sub></i>: (Field × [Bind]) → Field. This desugars object
1348 assertions.
1349 </p>
1350 <div class="desugar-rule">
1351 \[
1352 desugar_{assert}(\assert e, binds) =
1353 desugar_{assert}(\assert e : \texttt{"Assertion failed"}, binds)
1354 \]
1355 </div>
1356 <div class="desugar-rule">
1357 \[
1358 desugar_{assert}(\assert e : e', binds) =
1359 \assert{desugar_{expr}(\local{binds}{\if{e}{\null}{\error{e'}}}, \true)}
1360 \]
1361 </div>
1362 </div>
1363 <div class="desugar-rule-group">
1364 <p>
1365 <i>desugar<sub>field</sub></i>: (Field × [Bind] × Boolean) → Field. This desugars object fields.
1366 Recall that <i>h</i> ranges over <code>:</code>, <code>::</code>, <code>:::</code>. The
1367 boolean records whether the object containing this field is itself in another object. The
1368 notation <i>string(id)</i> means converting the identifier token to a string literal.
1369 </p>
1370 <div class="desugar-rule">
1371 \[
1372 desugar_{field}(id \mathrel{h} e, binds, b) =
1373 desugar_{field}([string(id)] \mathrel{h} e), binds, b)
1374 \]
1375 </div>
1376 <div class="desugar-rule">
1377 \[
1378 desugar_{field}(id \mathrel{+h} e, binds, b) =
1379 desugar_{field}([string(id)] \mathrel{+h} e), binds, b)
1380 \]
1381 </div>
1382 <div class="desugar-rule">
1383 \[
1384 desugar_{field}(id(params) \mathrel{h} e, binds, b) =
1385 desugar_{field}([string(id)](params) \mathrel{h} e), binds, b)
1386 \]
1387 </div>
1388 <div class="desugar-rule">
1389 \[
1390 desugar_{field}(string \mathrel{h} e, binds, b) =
1391 desugar_{field}([string] \mathrel{h} e), binds, b)
1392 \]
1393 </div>
1394 <div class="desugar-rule">
1395 \[
1396 desugar_{field}(string \mathrel{+h} e, binds, b) =
1397 desugar_{field}([string] \mathrel{+h} e), binds, b)
1398 \]
1399 </div>
1400 <div class="desugar-rule">
1401 \[
1402 desugar_{field}(string(params) \mathrel{h} e, binds, b) =
1403 desugar_{field}([string](params) \mathrel{h} e), binds, b)
1404 \]
1405 </div>
1406 <div class="desugar-rule">
1407 \[
1408 desugar_{field}([e] \mathrel{h} e', binds, b) =
1409 [desugar_{expr}(e, b)] \mathrel{h} desugar_{expr}(\local{binds}{e}, \true)
1410 \]
1411 </div>
1412 <div class="desugar-rule">
1413 \[
1414 desugar_{field}([e] \mathrel{+h} e', binds, b) = \\
1415 \hspace{10mm}
1416 \textrm{let } e'' = e[\texttt{\$outerself} / \self, \texttt{\$outersuper} / \super] \\
1417 \hspace{10mm}
1418 \textrm{let } e''' = \if{e''\mathrel{\texttt{in}} \super}{\super[e''] + {e'}}{e'} \\
1419 \hspace{10mm}
1420 \textrm{in } desugar_{field}([e] \mathrel{h} e''', binds, b)
1421 \]
1422 </div>
1423 <div class="desugar-rule">
1424 \[
1425 desugar_{field}([e](params) \mathrel{h} e', binds, b) =
1426 desugar_{field}([e] \mathrel{h} \function{params}{e'}, binds, b)
1427 \]
1428 </div>
1429 </div>
1430 <div class="desugar-rule-group">
1431 <p>
1432 <i>desugar<sub>bind</sub></i>: (Bind × Boolean) → Field. This desugars local bindings.
1433 </p>
1434 <div class="desugar-rule">
1435 \[
1436 desugar_{bind}(id \texttt{=} e, b) =
1437 id \texttt{=} desugar_{expr}(e, b)
1438 \]
1439 </div>
1440 <div class="desugar-rule">
1441 \[
1442 desugar_{bind}(id(params) \texttt{=} e, b) =
1443 id \texttt{=} desugar_{expr}(\function{params}e, b)
1444 \]
1445 </div>
1446 </div>
1447 <div class="desugar-rule-group">
1448 <p>
1449 <i>desugar<sub>param</sub></i>: (Param × Boolean) → Param. This desugars function parameters.
1450 </p>
1451 <div class="desugar-rule">
1452 \[
1453 desugar_{param}(id, b) =
1454 id \texttt{=} \error{\texttt{"Parameter not bound"}}
1455 \]
1456 </div>
1457 <div class="desugar-rule">
1458 \[
1459 desugar_{param}(id \texttt{=} e, b) =
1460 id \texttt{=} desugar_{expr}(e, b)
1461 \]
1462 </div>
1463 </div>
1464 <div class="desugar-rule-group">
1465 <p>
1466 <i>desugar<sub>arrcomp</sub></i>: (Expr × CompSpec × Boolean) → Field. This desugars
1467 array comprehensions.
1468 </p>
1469 <div class="desugar-rule">
1470 \[
1471 desugar_{arrcomp}(e, \textrm{if }e'\ compspec, b) =
1472 desugar_{expr}(\if{e'}{desugar_{arrcomp}(e, compspec, b)}{[\ ]}, b)
1473 \]
1474 </div>
1475 <div class="desugar-rule">
1476 \[
1477 desugar_{arrcomp}(e, \textrm{if }e', b) =
1478 desugar_{expr}(\if{e'}{[e]}{[\ ]}, b)
1479 \]
1480 </div>
1481 <div class="desugar-rule">
1482 \[
1483 desugar_{arrcomp}(e, \textrm{for }x\textrm{ in }e'\ compspec, b) = \\
1484 \hspace{10mm}\textrm{Let }arr, i\textrm{ fresh} \\
1485 \hspace{10mm}desugar_{expr}(
1486 \local{arr = e'}{
1487 \texttt{std.join}(\\\hspace{20mm}[\ ], \texttt{std.makeArray}(
1488 \texttt{std.length}(arr),
1489 \function{i}{\local{x = arr[i]}{desugar_{arrcomp}(e, compspec, b)}}
1490 ))
1491 },
1492 b
1493 )
1494 \]
1495 </div>
1496 <div class="desugar-rule">
1497 \[
1498 desugar_{arrcomp}(e, \textrm{for }x\textrm{ in }e', b) = \\
1499 \hspace{10mm}\textrm{Let }arr, i\textrm{ fresh} \\
1500 \hspace{10mm}desugar_{expr}(
1501 \local{arr = e'}{
1502 \texttt{std.join}(\\\hspace{20mm}[\ ], \texttt{std.makeArray}(
1503 \texttt{std.length}(arr),
1504 \function{i}{\local{x = arr[i]}{[e]}}
1505 ))
1506 },
1507 b
1508 )
1509 \]
1510 </div>
1511 </div>
1512 </div>
1513 <div style="clear: both"></div>
1514 </div>
1515 </div>
1516
1517
1518 <div class="hgroup">
1519 <div class="hgroup-inline">
1520 <div class="panel">
1521 <h3 id="static_checking">Static Checking</h3>
1522 </div>
1523 <div style="clear: both"></div>
1524 </div>
1525 </div>
1526
1527 <div class="hgroup">
1528 <div class="hgroup-inline">
1529 <div class="panel">
1530 <p>
1531 After the Jsonnet program is parsed and desugared, a syntax-directed algorithm is employed
1532 to reject programs that contain certain classes of errors. This is presented like a static
1533 type system, except that there are no static types. Programs are only rejected if they use
1534 undefined variables, or if <code>self</code>, <code>super</code> or <code>$</code> are used
1535 outside the bounds of an object. In the core language, <code>$</code> has been desugared to
1536 a variable, so its checking is implicit in the checking of bound variables.
1537 </p>
1538 <p>
1539 The static checking is described below as a judgement \(Γ ⊢ e\), where \(Γ\) is the set of
1540 variables in scope of \(e\). The set \(Γ\) initially contains only <code>std</code>, the
1541 implicit standard library. In the case of imported files, each jsonnet file is checked
1542 independently of the other files.
1543 </p>
1544 </div>
1545 <div style="clear: both"></div>
1546 </div>
1547 </div>
1548
1549
1550 <div class="inverse hgroup">
1551 <div class="hgroup-inline">
1552 <div class="panel wide">
1553 <div class="rules">
1554 <div class="sequent-rule">
1555 \[
1556 \rule{chk-lit} {
1557 } {
1558 \_ ⊢ \null, \true, \false, string, number
1559 }
1560 \]
1561 </div>
1562 <div class="sequent-rule">
1563 \[
1564 \rule{chk-self} {
1565 \self ∈ Γ
1566 } {
1567 Γ ⊢ \self
1568 }
1569 \]
1570 </div>
1571 <div class="sequent-rule">
1572 \[
1573 \rule{chk-super} {
1574 \super ∈ Γ
1575 } {
1576 Γ ⊢ \super
1577 }
1578 \]
1579 </div>
1580 <div class="sequent-rule">
1581 \[
1582 \rule{chk-object} {
1583 Γ ⊢ e_1 \ldots e_m
1584 \\
1585 Γ ∪ \{\self,\super\} ⊢ e'_1 \ldots e'_n
1586 \\
1587 ∀ i,j: e_i ∈ string ∧ e_j = e_i ⇒ i = j
1588 } {
1589 Γ ⊢ \object{[e_1] h_1 e'_1 \ldots [e_m] h_m e'_m,
1590 \assert e'_{m+1} \ldots \assert e'_n}
1591 }
1592 \]
1593 </div>
1594 <div class="sequent-rule">
1595 \[
1596 \rule{chk-object-comp} {
1597 Γ ∪ \{x\} ⊢ e_1
1598 \\
1599 Γ ∪ \{x,\self,\super\} ⊢ e_2
1600 \\
1601 Γ ⊢ e_3
1602 } {
1603 Γ ⊢ \ocomp{e_1}{e_2}{x}{e_3}
1604 }
1605 \]
1606 </div>
1607 <div class="sequent-rule">
1608 \[
1609 \rule{chk-array} {
1610 Γ ⊢ e_1 \ldots e_n
1611 } {
1612 Γ ⊢ \array{e_1 \ldots e_n}
1613 }
1614 \]
1615 </div>
1616 <div class="sequent-rule">
1617 \[
1618 \rule{chk-array-index} {
1619 Γ ⊢ e
1620 \\
1621 Γ ⊢ e'
1622 } {
1623 Γ ⊢ e[e']
1624 }
1625 \]
1626 </div>
1627 <div class="sequent-rule">
1628 \[
1629 \rule{chk-apply} {
1630 Γ ⊢ e
1631 \\
1632 ∀ i∈\{1\ldots n\}: Γ ⊢ e_i
1633 \\
1634 ∀ i,j∈\{1\ldots n\}: x_i = x_j ⇒ i = j
1635 } {
1636 Γ ⊢ e(x_1 = e_1 \ldots x_n = e_n)
1637 }
1638 \]
1639 </div>
1640 <div class="sequent-rule">
1641 \[
1642 \rule{chk-var} {
1643 x ∈ Γ
1644 } {
1645 Γ ⊢ x
1646 }
1647 \]
1648 </div>
1649 <div class="sequent-rule">
1650 \[
1651 \rule{chk-local} {
1652 Γ ∪ \{x_1 \ldots x_n\} ⊢ e_1 \ldots e_n, e
1653 \\
1654 ∀ i,j: x_i = x_j ⇒ i = j
1655 } {
1656 Γ ⊢ \local{\assign{x_1}{e_1} \ldots \assign{x_n}{e_n}}e
1657 }
1658 \]
1659 </div>
1660 <div class="sequent-rule">
1661 \[
1662 \rule{chk-if} {
1663 Γ ⊢ e_1, e_2, e_3
1664 } {
1665 Γ ⊢ \if{e_1}{e_2}{e_3}
1666 }
1667 \]
1668 </div>
1669 <div class="sequent-rule">
1670 \[
1671 \rule{chk-binary} {
1672 Γ ⊢ e_L, e_R
1673 } {
1674 Γ ⊢ \binary{e_L}{sym}{e_R}
1675 }
1676 \]
1677 </div>
1678 <div class="sequent-rule">
1679 \[
1680 \rule{chk-unary} {
1681 Γ ⊢ e
1682 } {
1683 Γ ⊢ \unary{sym}{e}
1684 }
1685 \]
1686 </div>
1687 <div class="sequent-rule">
1688 \[
1689 \rule{chk-function} {
1690 ∀ i ∈ \{m+1 \ldots n\}: Γ ∪ \{x_1 \ldots x_n\} ⊢ e_i
1691 \\
1692 Γ ∪ \{x_1 \ldots x_n\} ⊢ e'
1693 \\
1694 ∀ i,j: x_i = x_j ⇒ i = j
1695 } {
1696 Γ ⊢ \function{x_1\ldots x_m, x_{m+1}=e_{m+1}\ldots x_n=e_n}{e'}
1697 }
1698 \]
1699 </div>
1700 <div class="sequent-rule">
1701 \[
1702 \rule{chk-import} {
1703 } {
1704 Γ ⊢ \import{s}
1705 }
1706 \]
1707 </div>
1708 <div class="sequent-rule">
1709 \[
1710 \rule{chk-importstr} {
1711 } {
1712 Γ ⊢ \importstr{s}
1713 }
1714 \]
1715 </div>
1716 <div class="sequent-rule">
1717 \[
1718 \rule{chk-importbin} {
1719 } {
1720 Γ ⊢ \importbin{s}
1721 }
1722 \]
1723 </div>
1724 <div class="sequent-rule">
1725 \[
1726 \rule{chk-error} {
1727 Γ ⊢ e
1728 } {
1729 Γ ⊢ \error{e}
1730 }
1731 \]
1732 </div>
1733 </div>
1734 </div>
1735 <div style="clear: both"></div>
1736 </div>
1737 </div>
1738
1739
1740 <div class="hgroup">
1741 <div class="hgroup-inline">
1742 <div class="panel">
1743 <h3 id="semantics">Operational Semantics</h3>
1744 </div>
1745 <div style="clear: both"></div>
1746 </div>
1747 </div>
1748
1749 <div class="hgroup">
1750 <div class="hgroup-inline">
1751 <div class="panel">
1752 <p>
1753 We present two sets of operational semantics rules. The first defines the judgement \(e ↓
1754 v\) which represents the execution of Jsonnet expressions into Jsonnet values. The other
1755 defines the judgement \(v ⇓ j\) which represents <dfn>manifestation</dfn>, the process by
1756 which Jsonnet values are converted into JSON values.
1757 </p>
1758
1759 <p>
1760 We model both explicit runtime errors (raised by the error construct) and implicit runtime
1761 errors (e.g. array bounds errors) as stuck execution. Errors can occur both in the \(e ↓
1762 v\) judgement and in the \(v ⇓ j\) judgement (because it is defined in terms of \(e ↓ v\)).
1763 </p>
1764 </div>
1765 <div style="clear: both"></div>
1766 </div>
1767 </div>
1768
1769 <div class="hgroup">
1770 <div class="hgroup-inline">
1771 <div class="panel">
1772 <h4 id="jsonnet_values">Jsonnet Values</h4>
1773 </div>
1774 <div style="clear: both"></div>
1775 </div>
1776 </div>
1777
1778 <div class="hgroup">
1779 <div class="hgroup-inline">
1780 <div class="panel">
1781 <p>
1782 When executed, Jsonnet expressions yield Jsonnet values. These need to be manifested, an
1783 additional step, to get JSON values. The differences between Jsonnet values and JSON values
1784 are: 1) Jsonnet values contain functions (which are not representable in JSON). 2) Due to
1785 the lazy semantics, both object fields and array elements have yet to be executed to yield
1786 values. 3) Object assertions still need to be checked.
1787 </p>
1788 <p>
1789 Execution of a statically-checked expression will never yield an object with duplicate field
1790 names. By abuse of notation, we consider two objects to be equivalent even if their fields
1791 and assertions are re-ordered. However this is not true of array elements or function
1792 parameters.
1793 </p>
1794 </div>
1795 <div style="clear: both"></div>
1796 </div>
1797 </div>
1798
1799 <div class="inverse hgroup">
1800 <div class="hgroup-inline">
1801 <div class="panel wide">
1802 <table>
1803 <tr>
1804 <td><em>v</em></td>
1805 <td>∈</td>
1806 <td><em>Value</em></td>
1807 <td>=</td>
1808 <td>
1809 <em>Primitive</em> ∪
1810 <em>Object</em> ∪
1811 <em>Function</em> ∪
1812 <em>Array</em>
1813 </td>
1814 </tr>
1815 <tr>
1816 <td></td>
1817 <td></td>
1818 <td><em>Primitive</em></td>
1819 <td>::=</td>
1820 <td>
1821 <code>null</code> | <code>true</code> | <code>false</code> | <i>string</i>
1822 | <i>double</i>
1823 </td>
1824 </tr>
1825 <tr>
1826 <td><em>o</em></td>
1827 <td>∈</td>
1828 <td><em>Object</em></td>
1829 <td>::=</td>
1830 <td>
1831 <code>{</code>
1832 { <code>assert</code> <i>e</i> } { <i>string</i> <i>h</i> <i>e</i> }
1833 <code>}</code>
1834 </td>
1835 </tr>
1836 <tr>
1837 <td></td>
1838 <td></td>
1839 <td><em>Function</em></td>
1840 <td>::=</td>
1841 <td>
1842 <code>function (</code> { <i>id</i>=<i>e</i> } <code>)</code> <i>e</i>
1843 </td>
1844 </tr>
1845 <tr>
1846 <td><em>a</em></td>
1847 <td>∈</td>
1848 <td><em>Array</em></td>
1849 <td>::=</td>
1850 <td>
1851 <code>[</code> { <i>e</i> } <code>]</code>
1852 </td>
1853 </tr>
1854 </table>
1855 </div>
1856 <div style="clear: both"></div>
1857 </div>
1858 </div>
1859
1860 <div class="hgroup">
1861 <div class="hgroup-inline">
1862 <div class="panel">
1863 <h4 id="hidden_inheritance">Hidden status inheritance</h4>
1864 </div>
1865 <div style="clear: both"></div>
1866 </div>
1867 </div>
1868
1869 <div class="hgroup">
1870 <div class="hgroup-inline">
1871 <div class="panel">
1872 <p>
1873 The hidden status of fields is preserved over inheritance if the right hand side uses the
1874 <code>:</code> form. This is codified with the following function:
1875 </p>
1876 <div class="rules">
1877 <div class="sequent-rule">
1878 \[
1879 h_L + h_R = \left\{\begin{array}{ll}
1880 h_L &amp; \textrm{if }h_R = \texttt{:} \\
1881 h_R &amp; \textrm{otherwise} \\
1882 \end{array}\right.
1883 \]
1884 </div>
1885 </div>
1886 </div>
1887 <div style="clear: both"></div>
1888 </div>
1889 </div>
1890
1891 <div class="hgroup">
1892 <div class="hgroup-inline">
1893 <div class="panel">
1894 <h4 id="substitution">Capture-Avoiding Substitution</h4>
1895 </div>
1896 <div style="clear: both"></div>
1897 </div>
1898 </div>
1899
1900 <div class="hgroup">
1901 <div class="hgroup-inline">
1902 <div class="panel">
1903 <p>
1904 The rules for capture-avoiding variable substitution [<i>e</i>/<i>id</i>] are an
1905 extension of those in the <a href="https://en.wikipedia.org/wiki/Lambda_calculus">lambda
1906 calculus</a>.
1907 </p>
1908 </div>
1909 <div style="clear: both"></div>
1910 </div>
1911 </div>
1912
1913 <div class="inverse hgroup">
1914 <div class="hgroup-inline">
1915 <div class="panel wide">
1916 <p>Let y ≠ x.</p>
1917 <table>
1918 <tr>
1919 <td>
1920 <code>self</code>[<i>e</i>/<i>x</i>] = <code>self</code>
1921 </td>
1922 </tr>
1923 <tr>
1924 <td>
1925 <code>super</code>[<i>e</i>/<i>x</i>] = <code>super</code>
1926 </td>
1927 </tr>
1928 <tr>
1929 <td>
1930 <i>x</i>[<i>e</i>/<i>x</i>] = <i>e</i>
1931 </td>
1932 </tr>
1933 <tr>
1934 <td>
1935 <i>y</i>[<i>e</i>/<i>x</i>] = <i>y</i>
1936 </td>
1937 </tr>
1938 <tr>
1939 <td colspan=2>
1940 <code>{</code>
1941 ...
1942 <code>assert</code> <i>e'</i>
1943 ...
1944 <code>[</code><i>e''</i><code>]</code> <i>h</i> <i>e'''</i>
1945 ...
1946 <code>}</code>[<i>e</i>/<i>x</i>] =
1947 <code>{</code>
1948 ...
1949 <code>assert</code> <i>e'</i>[<i>e</i>/<i>x</i>]
1950 ...
1951 <code>[</code><i>e'</i>[<i>e</i>/<i>x</i>]<code>]</code> <i>h</i>
1952 <i>e''</i>[<i>e</i>/<i>x</i>]
1953 ...
1954 <code>}</code>
1955 </td>
1956 </tr>
1957 <tr>
1958 <td>
1959 <code>{</code>
1960 <code>[</code><i>e'</i><code>]</code><code>:</code> <i>e''</i>
1961 <code>for</code> <i>x</i> <code>in</code> <i>e'''</i>
1962 <code>}</code>[<i>e</i>/<i>x</i>] =
1963 <code>{</code>
1964 <code>[</code><i>e'</i><code>]</code><code>:</code> <i>e''</i>
1965 <code>for</code> <i>x</i> <code>in</code> <i>e'''</i>[<i>e</i>/<i>x</i>]
1966 <code>}</code>
1967 </td>
1968 </tr>
1969 <tr>
1970 <td>
1971 <code>{</code>
1972 <code>[</code><i>e'</i><code>]</code><code>:</code> <i>e''</i>
1973 <code>for</code> <i>y</i> <code>in</code> <i>e'''</i>
1974 <code>}</code>[<i>e</i>/<i>x</i>] =
1975 <code>{</code>
1976 <code>[</code><i>e'</i>[<i>e</i>/<i>x</i>]<code>]:</code>
1977 <i>e''</i>[<i>e</i>/<i>x</i>]
1978 <code>for</code> <i>y</i> <code>in</code> <i>e'''</i> [<i>e</i>/<i>x</i>]
1979 <code>}</code>
1980 </td>
1981 </tr>
1982 <tr>
1983 <td>
1984 (<code>local</code> ... <i>y</i><code>=</code><i>e'</i> ... <code>;</code> <i>e''</i>)
1985 [<i>e</i>/<i>x</i>] =
1986 <code>local</code> ... <i>y</i><code>=</code><i>e'</i> ... <code>;</code> <i>e''</i>
1987 </td>
1988 <td>(If any variable matches.)</td>
1989 </tr>
1990 <tr>
1991 <td>
1992 (<code>local</code> ... <i>y</i><code>=</code><i>e'</i> ... <code>;</code> <i>e''</i>)
1993 [<i>e</i>/<i>x</i>] =
1994 <code>local</code> ... <i>y</i><code>=</code><i>e'</i>[<i>e</i>/<i>x</i>] ...
1995 <code>;</code><i>e''</i>[<i>e</i>/<i>x</i>]
1996 </td>
1997 <td>(If no variable matches.)</td>
1998 </tr>
1999 <tr>
2000 <td>
2001 (<code>function</code> <code>(</code>
2002 ... <i>y</i>=<i>e'</i> ...
2003 <code>)</code> <i>e''</i>)[<i>e</i>/<i>x</i>] =
2004 <code>function</code> <code>(</code>
2005 ... <i>y</i>=<i>e'</i> ...
2006 <code>)</code><i>e''</i>
2007 </td>
2008 <td>(If any param matches.)</td>
2009 </tr>
2010 <tr>
2011 <td>
2012 (<code>function</code> <code>(</code>
2013 ... <i>y</i>=<i>e'</i> ...
2014 <code>)</code> <i>e''</i>)[<i>e</i>/<i>x</i>] =
2015 <code>function</code> <code>(</code>
2016 ... <i>y</i>=<i>e'</i>[<i>e</i>/<i>x</i>] ...
2017 <code>)</code> <i>e''</i>[<i>e</i>/<i>x</i>]
2018 </td>
2019 <td>(If no param matches.)</td>
2020 </tr>
2021 <tr>
2022 <td>
2023 Otherwise, <i>e'</i> [<i>e</i>/<i>x</i>] proceeds via syntax-directed recursion into
2024 subterms of <i>e'</i>.
2025 </td>
2026 </tr>
2027 </table>
2028 </div>
2029 <div style="clear: both"></div>
2030 </div>
2031 </div>
2032
2033 <div class="hgroup">
2034 <div class="hgroup-inline">
2035 <div class="panel">
2036 <p>
2037 The rules for keyword substitution ⟦<i>e</i>/<i>kw</i>⟧ for <i>kw</i> ∈ { <code>self</code>,
2038 <code>super</code> } avoid substituting keywords that are captured by nested objects:
2039 </p>
2040 </div>
2041 <div style="clear: both"></div>
2042 </div>
2043 </div>
2044
2045 <div class="inverse hgroup">
2046 <div class="hgroup-inline">
2047 <div class="panel wide">
2048 <table>
2049 <tr>
2050 <td>
2051 <code>self</code>
2052 ⟦<i>e</i>/<code>self</code>⟧ = <i>e</i>
2053 </td>
2054 </tr>
2055 <tr>
2056 <td>
2057 <code>super</code>
2058 ⟦<i>e</i>/<code>super</code>⟧ = <i>e</i>
2059 </td>
2060 </tr>
2061 <tr>
2062 <td>
2063 <code>self</code>
2064 ⟦<i>e</i>/<code>super</code>⟧ = <code>self</code>
2065 </td>
2066 </tr>
2067 <tr>
2068 <td>
2069 <code>super</code>
2070 ⟦<i>e</i>/<code>self</code>⟧ = <code>super</code>
2071 </td>
2072 </tr>
2073 <tr>
2074 <td>
2075 <code>{</code>
2076 ...
2077 <code>assert</code> <i>e'</i>
2078 ...
2079 <code>[</code><i>e''</i><code>]</code><i>h</i> <i>e'''</i>
2080 ...
2081 <code>}</code>
2082 ⟦<i>e</i>/<i>kw</i>⟧ =
2083 <code>{</code>
2084 ...
2085 <code>assert</code> <i>e'</i>
2086 ...
2087 <code>[</code><i>e''</i>⟦<i>e</i>/<i>kw</i>⟧<code>]</code><i>h</i> <i>e'''</i>
2088 ...
2089 <code>}</code>
2090 </td>
2091 </tr>
2092 <tr>
2093 <td>
2094 <code>{</code>
2095 <code>[</code><i>e'</i><code>]</code><code>:</code> <i>e''</i>
2096 <code>for</code> <i>x</i> <code>in</code> <i>e'''</i>
2097 <code>}</code>⟦<i>e</i>/<i>kw</i>⟧ =
2098 <code>{</code>
2099 <code>[</code><i>e'</i>⟦<i>e'</i>/<i>kw</i>⟧<code>]</code><code>:</code> <i>e''</i>
2100 <code>for</code> <i>x</i> <code>in</code> <i>e'''</i>⟦<i>e</i>/<i>kw</i>⟧
2101 <code>}</code>
2102 </td>
2103 </tr>
2104 <tr>
2105 <td>
2106 Otherwise, <i>e'</i>⟦<i>e'</i>/<i>kw</i>⟧ proceeds via syntax-directed recursion into
2107 the subterms of <i>e'</i>.
2108 </td>
2109 </tr>
2110 </table>
2111 </div>
2112 <div style="clear: both"></div>
2113 </div>
2114 </div>
2115
2116
2117 <div class="hgroup">
2118 <div class="hgroup-inline">
2119 <div class="panel">
2120 <h4 id="execution">Execution</h4>
2121 </div>
2122 <div style="clear: both"></div>
2123 </div>
2124 </div>
2125
2126 <div class="hgroup">
2127 <div class="hgroup-inline">
2128 <div class="panel">
2129 <p>
2130 The following big step operational semantics rules define the execution of Jsonnet programs,
2131 i.e. the reduction of a Jsonnet program <i>e</i> into its Jsonnet value <em>v</em> via the
2132 judgement \(e ↓ v\).
2133 </p>
2134 <div style="clear: both"></div>
2135 </div>
2136 </div>
2137
2138
2139 <div class="inverse hgroup">
2140 <div class="hgroup-inline">
2141 <div class="panel wide">
2142 <p>
2143 Let <em>f</em> range over strings, as used in object field names.
2144 </p>
2145 <div class="rules">
2146
2147 <div class="sequent-rule">
2148 \[
2149 \rule{value} {
2150 v ∈ \{\null, \true, \false\} ∪ String ∪ Number ∪ Function ∪ Array
2151 } {
2152 v ↓ v
2153 }
2154 \]
2155 </div>
2156
2157 <div class="sequent-rule">
2158 \[
2159 \rule{object} {
2160 ∀i∈\{1\ldots p\}: e_i ↓ f_i
2161 \\
2162 ∀i∈\{p+1 \ldots n\}: e_i ↓ \null
2163 \\
2164 ∀i,j∈\{1\ldots p\}: f_i = f_j ⇒ i = j
2165 \\
2166 o = \object{
2167 \assert{e_1} \ldots \assert{e_m}, f_1\mathop{h_1}e''_1 \ldots f_p\mathop{h_p}e''_p
2168 }
2169 } {
2170 \object{\assert{e_1} \ldots \assert{e_m},
2171 [e'_1]\mathop{h_1}e''_1 \ldots [e'_n]\mathop{h_n}e''_n } ↓ o
2172 }
2173 \]
2174 </div>
2175
2176 <div class="sequent-rule">
2177 \[
2178 \rule{object-comp} {
2179 e_{arr} ↓ [ e_1 \ldots e_n ]
2180 \\
2181 ∀i∈\{1 \ldots n\}: e_{field}[e_i/x] ↓ f_i
2182 \\
2183 ∀i,j∈\{1\ldots n\}: f_i = f_j ≠ \null ⇒ i = j
2184 \\
2185 \{ (f'_1, e'_1) \ldots (f'_m, e'_m) \} =
2186 \{ (f_i, e_{body}[e_i/x]) \ | \ i ∈\{1\ldots n\} ∧ f_i ≠ \null \}
2187 \\
2188 o = \object{f'_1: e'_1 \ldots f'_m: e'_m}
2189 } {
2190 \ocomp{e_{field}}{e_{body}}{x}{e_{arr}} ↓ o
2191 }
2192 \]
2193 </div>
2194
2195 <div class="sequent-rule">
2196 \[
2197 \rule{array-index} {
2198 e ↓ \array{e_0 \ldots e_n}
2199 \\
2200 e' ↓ i ∈ \{ 0 \ldots n \}
2201 \\
2202 e_i ↓ v
2203 } {
2204 \index{e}{e'} ↓ v
2205 }
2206 \]
2207 </div>
2208
2209 <div class="sequent-rule">
2210 \[
2211 \rule{object-index} {
2212 e ↓ o = \object{\assert{e'''_1} \ldots \assert{e'''_m}, f_1 h_1 e''_1 \ldots f_n h_n e''_n}
2213 \\
2214 ∀j ∈ \{1 \ldots m \}: e'''_j⟦ o / \self, \{\} / \super ⟧↓\_
2215 \\
2216 e' ↓ f_i
2217 \\
2218 e''_i ⟦ o / \self, \{\} / \super ⟧ ↓ v
2219 } {
2220 \index{e}{e'} ↓ v
2221 }
2222 \]
2223 </div>
2224
2225 <div class="sequent-rule">
2226 \[
2227 \rule{apply} {
2228 e_0 ↓ \function{y_1=e'_1 \ldots y_p=e'_p}{e_b}
2229 \\
2230 ∀i∈\{m+1 \ldots n\}: x_i ∈ \{y_1 \ldots y_p\}
2231 \\
2232 ∀i∈\{1 \ldots p\}: e''_i = \left\{\begin{array}{ll}
2233 e_i &amp; \textrm{if } i &le; m \\
2234 e_j &amp; \textrm{if } y_i=x_j \textrm{ for some } j \\
2235 e'_i &amp; \textrm{otherwise}\\
2236 \end{array}\right.
2237 \\
2238 (\local{y_1=e''_1 \ldots y_p=e''_p}{e_b}) ↓ v
2239 } {
2240 e_0(e_1 \ldots e_m, x_{m+1}=e_{m+1} \ldots x_n = e_n) ↓ v
2241 }
2242 \]
2243 </div>
2244
2245 <div class="sequent-rule">
2246 \[
2247 \rule{local} {
2248 e ↓ v
2249 } {
2250 \local{\_}e ↓ v
2251 }
2252 \]
2253 </div>
2254
2255 <div class="sequent-rule">
2256 \[
2257 \rule{local-var} {
2258 binds = \assign{x_1}{e_1} \ldots \assign{x_n}{e_n}
2259 \\
2260 \local{binds}{e[\local{binds}{e_1} / x_1 \ldots \local{binds}{e_n} / x_n ]} ↓ v
2261 } {
2262 \local{binds}e ↓ v
2263 }
2264 \]
2265 </div>
2266
2267 <div class="sequent-rule">
2268 \[
2269 \rule{if-true} {
2270 e_1 ↓ \true \hspace{15pt} e_2 ↓ v
2271 } {
2272 \if{e_1}{e_2}{e_3} ↓ v
2273 }
2274 \]
2275 </div>
2276
2277 <div class="sequent-rule">
2278 \[
2279 \rule{if-false} {
2280 e_1 ↓ \false \hspace{15pt} e_3 ↓ v
2281 } {
2282 \if{e_1}{e_2}{e_3} ↓ v
2283 }
2284 \]
2285 </div>
2286
2287 <div class="sequent-rule">
2288 \[
2289 \rule{object-inherit} {
2290 e^L ↓ \object{
2291 \assert e''^L_1 \ldots \assert e''^L_n,\
2292 f_1 h^L_1 e^L_1 \ldots f_m h^L_m e^L_m,\
2293 f'^L_1 h'^L_1 e'^L_1 \ldots f'^L_p h'^L_p e'^L_p
2294 }
2295 \\
2296 e^R ↓ \object{
2297 \assert e''^R_1 \ldots \assert e''^R_q,\
2298 f_1 h^R_1 e^R_1 \ldots f_m h^R_m e^R_m,\
2299 f'^R_1 h'^R_1 e'^R_1 \ldots f'^R_r h'^R_r e'^R_r
2300 }
2301 \\
2302 \{ f'^L_1 \ldots f'^L_p \} ∩ \{ f'^R_1 \ldots f'^R_r \} = ∅
2303 \\
2304 x, y \textrm{ fresh} \hspace{15pt} \textrm{let } S = λe . e⟦x/\self, y/\super⟧
2305 \\
2306 e_s = \super + \object{
2307 \assert S(e''^L_1) \ldots \assert S(e''^L_n),\\
2308 \hspace{20mm}
2309 f_1 h^L_1 S(e^L_1) \ldots f_m h^L_m S(e^L_m),\
2310 f'^L_1 h'^L_1 S(e'^L_1) \ldots f'^L_p h'^L_p S(e'^L_p)
2311 }
2312 \\
2313 ∀i∈\{1 \ldots m\}: h'''_i = h^L_i + h^R_i ∧
2314 e'''_i = (\local{x = \self, y = \super}{e^R_i ⟦e_s / \super⟧})
2315 \\
2316 o = \{ \\
2317 \hspace{5mm} \assert e''^L_1 \ldots \assert e''^L_n, \
2318 \assert e''^R_1 \ldots \assert e''^R_q, \\
2319 \hspace{5mm} f'^L_1 h'^L_1 e'^L_1 \ldots f'^L_p h'^L_p e'^L_p, \
2320 f'^R_1 h'^R_1 e'^R_1 \ldots f'^R_r h'^R_r e'^R_r, \
2321 f_1 h'''_1 e'''_m \ldots f_m h'''_m e'''_m \\
2322 \}
2323 } {
2324 e^L \texttt{ + } e^R ↓ o
2325 }
2326 \]
2327 </div>
2328
2329 <div class="sequent-rule">
2330 \[
2331 \rule{array-concat} {
2332 e ↓ \array{e_0 \ldots e_m}
2333 \\
2334 e' ↓ \array{e_{m+1} \ldots e_n}
2335 } {
2336 e + e' ↓ \array{e_1 \ldots e_n}
2337 }
2338 \]
2339 </div>
2340
2341 <div class="sequent-rule">
2342 \[
2343 \rule{string-concat} {
2344 e_L ↓ v_L \hspace{15pt} e_R ↓ v_R
2345 \\
2346 v_L ∈ String \vee v_R ∈ String
2347 } {
2348 e_L \texttt{ + } e_R ↓ stringconcat(tostring(v_L), tostring(v_R))
2349 }
2350 \]
2351 </div>
2352
2353 <!-- TODO(sbarzowski) Consider explicitly introducing std.cmp (three way comparison) -->
2354 <div class="sequent-rule">
2355 \[
2356 \rule{less-than-true} {
2357 \texttt{std.cmp}(e_L, e_R) ↓ -1
2358 } {
2359 e_L &lt; e_R ↓ \texttt{true}
2360 }
2361 \]
2362 </div>
2363
2364 <div class="sequent-rule">
2365 \[
2366 \rule{less-than-false} {
2367 \texttt{std.cmp}(e_L, e_R) ↓ r
2368 \\
2369 r ∈ \{0, 1\}
2370 } {
2371 e_L &lt; e_R ↓ \texttt{false}
2372 }
2373 \]
2374 </div>
2375
2376 <div class="sequent-rule">
2377 \[
2378 \rule{greater-than-true} {
2379 \texttt{std.cmp}(e_L, e_R) ↓ 1
2380 } {
2381 e_L &lt; e_R ↓ \texttt{true}
2382 }
2383 \]
2384 </div>
2385
2386 <div class="sequent-rule">
2387 \[
2388 \rule{greater-than-false} {
2389 \texttt{std.cmp}(e_L, e_R) ↓ r
2390 \\
2391 r ∈ \{-1, 0\}
2392 } {
2393 e_L &lt; e_R ↓ \texttt{false}
2394 }
2395 \]
2396 </div>
2397
2398 <div class="sequent-rule">
2399 \[
2400 \rule{less-or-equal-true} {
2401 \texttt{std.cmp}(e_L, e_R) ↓ r
2402 \\
2403 r ∈ \{-1, 0\}
2404 } {
2405 e_L &lt;= e_R ↓ \texttt{true}
2406 }
2407 \]
2408 </div>
2409
2410 <div class="sequent-rule">
2411 \[
2412 \rule{less-or-equal-false} {
2413 \texttt{std.cmp}(e_L, e_R) ↓ 1
2414 } {
2415 e_L &lt;= e_R ↓ \texttt{false}
2416 }
2417 \]
2418 </div>
2419
2420 <div class="sequent-rule">
2421 \[
2422 \rule{greater-or-equal-true} {
2423 \texttt{std.cmp}(e_L, e_R) ↓ r
2424 \\
2425 r ∈ \{0, 1\}
2426 } {
2427 e_L &gt;= e_R ↓ \texttt{true}
2428 }
2429 \]
2430 </div>
2431
2432 <div class="sequent-rule">
2433 \[
2434 \rule{greater-or-equal-false} {
2435 \texttt{std.cmp}(e_L, e_R) ↓ -1
2436 } {
2437 e_L &gt;= e_R ↓ \texttt{false}
2438 }
2439 \]
2440 </div>
2441
2442 <div class="sequent-rule">
2443 \[
2444 \rule{cmp-array-left-empty} {
2445 e_L ↓ \array{} \hspace{15pt} e_R ↓ \array{a_0 \ldots a_{n - 1}}
2446 \\
2447 n &gt 0
2448 } {
2449 \texttt{std.cmp}(e_L, e_R) ↓ -1
2450 }
2451 \]
2452 </div>
2453
2454 <div class="sequent-rule">
2455 \[
2456 \rule{cmp-array-right-empty} {
2457 e_L ↓ \array{a_0 \ldots a_{n - 1}} \hspace{15pt} e_R ↓ \array{}
2458 \\
2459 n &gt 0
2460 } {
2461 \texttt{std.cmp}(e_L, e_R) ↓ 1
2462 }
2463 \]
2464 </div>
2465
2466 <div class="sequent-rule">
2467 \[
2468 \rule{cmp-array-both-empty} {
2469 e_L ↓ \array{} \hspace{15pt} e_R ↓ \array{}
2470 } {
2471 \texttt{std.cmp}(e_L, e_R) ↓ 0
2472 }
2473 \]
2474 </div>
2475
2476 <div class="sequent-rule">
2477 \[
2478 \rule{cmp-array-first-different} {
2479 e_L ↓ \array{a_0 \ldots a_{n - 1}} \hspace{15pt} e_R ↓ \array{b_0 \ldots b_{m - 1}}
2480 \\
2481 n > 0 \hspace{15pt} m > 0
2482 \\
2483 \texttt{std.cmp}(a_0, b_0) ↓ r
2484 \\
2485 r ≠ 0
2486 } {
2487 \texttt{std.cmp}(e_L, e_R) ↓ r
2488 }
2489 \]
2490 </div>
2491
2492 <div class="sequent-rule">
2493 \[
2494 \rule{cmp-array-first-equal} {
2495 e_L ↓ \array{a_0 \ldots a_{n - 1}} \hspace{15pt} e_R ↓ \array{b_0 \ldots b_{m - 1}}
2496 \\
2497 n > 0 \hspace{15pt} m > 0
2498 \\
2499 \texttt{std.cmp}(a_0, b_0) ↓ 0
2500 \\
2501 \texttt{std.cmp}(\array{a_1 \ldots a_{n - 1}}, \array{b_1 \ldots b_{m - 1}}) ↓ r'
2502 } {
2503 \texttt{std.cmp}(e_L, e_R) ↓ r'
2504 }
2505 \]
2506 </div>
2507
2508 <div class="sequent-rule">
2509 \[
2510 \rule{cmp-string} {
2511 e_L ↓ v_L \hspace{15pt} e_R ↓ v_R
2512 \\
2513 v_L ∈ String
2514 \\
2515 v_R ∈ String
2516 } {
2517 \texttt{std.cmp}(e_L, e_R) ↓ stringcmp(v_L, v_R)
2518 }
2519 \]
2520 </div>
2521
2522 <div class="sequent-rule">
2523 \[
2524 \rule{cmp-number} {
2525 e_L ↓ v_L \hspace{15pt} e_R ↓ v_R
2526 \\
2527 v_L ∈ Number
2528 \\
2529 v_R ∈ Number
2530 } {
2531 \texttt{std.cmp}(e_L, e_R) ↓ numbercmp(v_L, v_R)
2532 }
2533 \]
2534 </div>
2535
2536 <div class="sequent-rule">
2537 \[
2538 \rule{boolean-and-shortcut} {
2539 e_L ↓ \false
2540 } {
2541 e_L \texttt{ &amp;&amp; } e_R ↓ \false
2542 }
2543 \]
2544 </div>
2545
2546 <div class="sequent-rule">
2547 \[
2548 \rule{boolean-and-longcut} {
2549 e_L ↓ \true
2550 \\
2551 e_R ↓ b
2552 } {
2553 e_L \texttt{ &amp;&amp; } e_R ↓ b
2554 }
2555 \]
2556 </div>
2557
2558 <div class="sequent-rule">
2559 \[
2560 \rule{boolean-or-shortcut} {
2561 e_L ↓ \true
2562 } {
2563 e_L \texttt{ || } e_R ↓ \true
2564 }
2565 \]
2566 </div>
2567
2568 <div class="sequent-rule">
2569 \[
2570 \rule{boolean-or-longcut} {
2571 e_L ↓ \false
2572 \\
2573 e_R ↓ b
2574 } {
2575 e_L \texttt{ || } e_R ↓ b
2576 }
2577 \]
2578 </div>
2579
2580 <div class="sequent-rule">
2581 \[
2582 \rule{not-true} {
2583 e ↓ \true
2584 } {
2585 \texttt{!} e ↓ \false
2586 }
2587 \]
2588 </div>
2589
2590 <div class="sequent-rule">
2591 \[
2592 \rule{not-false} {
2593 e ↓ \false
2594 } {
2595 \texttt{!} e ↓ \true
2596 }
2597 \]
2598 </div>
2599
2600 <div class="sequent-rule">
2601 \[
2602 \rule{primitiveEquals} {
2603 e ↓ v
2604 \\
2605 e' ↓ v'
2606 \\
2607 b = (v ∈ String ∨ v ∈ Boolean ∨ v ∈ Number ∨ v = \null) ∧ v = v'
2608 } {
2609 \texttt{std.primitiveEquals}(e, e') ↓ b
2610 }
2611 \]
2612 </div>
2613
2614 <div class="sequent-rule">
2615 \[
2616 \rule{length-array} {
2617 e ↓ \array{e_0 \ldots e_{n - 1}}
2618 } {
2619 \texttt{std.length}(e) ↓ n
2620 }
2621 \]
2622 </div>
2623
2624 <div class="sequent-rule">
2625 \[
2626 \rule{length-object} {
2627 \texttt{std.length}(\texttt{std.objectFieldsEx}(e, false) ↓ n
2628 } {
2629 \texttt{std.length}(e) ↓ n
2630 }
2631 \]
2632 </div>
2633
2634 <div class="sequent-rule">
2635 \[
2636 \rule{length-string} {
2637 e ↓ v ∈ String
2638 } {
2639 \texttt{std.length}(e) ↓ strlen(v)
2640 }
2641 \]
2642 </div>
2643
2644 <div class="sequent-rule">
2645 \[
2646 \rule{makeArray} {
2647 e ↓ n
2648 \\
2649 e' ↓ f ∈ Function
2650 } {
2651 \texttt{std.makeArray}(e, e') ↓ \array{f(0) \ldots f(n - 1)}
2652 }
2653 \]
2654 </div>
2655
2656 <div class="sequent-rule">
2657 \[
2658 \rule{filter} {
2659 e ↓ f ∈ Function
2660 \\
2661 e' ↓ \array{e_0 \ldots e_{n - 1}}
2662 \\
2663 j_1 \ldots j_m = \{ i \ |\ f(e_i) ↓ \true \}
2664 } {
2665 \texttt{std.filter}(e, e') ↓ \array{e_{j_1} \ldots e_{j_m}}
2666 }
2667 \]
2668 </div>
2669
2670 <div class="sequent-rule">
2671 \[
2672 \rule{type-null} {
2673 e ↓ \texttt{null}
2674 } {
2675 \texttt{std.type}(e) ↓ \texttt{"null"}
2676 }
2677 \]
2678 </div>
2679
2680 <div class="sequent-rule">
2681 \[
2682 \rule{type-boolean} {
2683 e ↓ v ∈ Boolean
2684 } {
2685 \texttt{std.type}(e) ↓ \texttt{"boolean"}
2686 }
2687 \]
2688 </div>
2689
2690 <div class="sequent-rule">
2691 \[
2692 \rule{type-number} {
2693 e ↓ v ∈ Number
2694 } {
2695 \texttt{std.type}(e) ↓ \texttt{"number"}
2696 }
2697 \]
2698 </div>
2699
2700 <div class="sequent-rule">
2701 \[
2702 \rule{type-string} {
2703 e ↓ v ∈ String
2704 } {
2705 \texttt{std.type}(e) ↓ \texttt{"string"}
2706 }
2707 \]
2708 </div>
2709
2710 <div class="sequent-rule">
2711 \[
2712 \rule{type-object} {
2713 e ↓ v ∈ Object
2714 } {
2715 \texttt{std.type}(e) ↓ \texttt{"object"}
2716 }
2717 \]
2718 </div>
2719
2720 <div class="sequent-rule">
2721 \[
2722 \rule{type-function} {
2723 e ↓ v ∈ Function
2724 } {
2725 \texttt{std.type}(e) ↓ \texttt{"function"}
2726 }
2727 \]
2728 </div>
2729
2730 <div class="sequent-rule">
2731 \[
2732 \rule{type-array} {
2733 e ↓ v ∈ Array
2734 } {
2735 \texttt{std.type}(e) ↓ \texttt{"array"}
2736 }
2737 \]
2738 </div>
2739
2740 <div class="sequent-rule">
2741 \[
2742 \rule{object-has-ex} {
2743 e' ↓ f
2744 \\
2745 e'' ↓ b'
2746 \\
2747 e ↓ \object{\assert{e'_1} \ldots \assert{e'_m}, f_1 h_1 e_1 \ldots f_n h_n e_n }
2748 \\
2749 b = ∃i: f = f_i ∧ (h_i \mathop{≠} :: \mathop{∨} b')
2750 } {
2751 \texttt{std.objectHasEx}(e, e', e'') ↓ b
2752 }
2753 \]
2754 </div>
2755
2756 <div class="sequent-rule">
2757 \[
2758 \rule{object-fields-ex} {
2759 e' ↓ b'
2760 \\
2761 e ↓ \object{\assert{e'_1} \ldots \assert{e'_m}, f_1 h_1 e_1 \ldots f_n h_n e_n }
2762 \\
2763 \{ f'_1 \ldots f'_p \} = \{ f\ |\ ∃i: f = f_i ∧ (h_i \mathop{≠} :: \mathop{∨} b') \}
2764 \\
2765 ∀i,j∈\{1 \ldots p\}: i≤j ⇒ f'_i≤f'_j
2766 } {
2767 \texttt{std.objectFieldsEx}(e, e') ↓ \array{f'_1 \ldots f'_p}
2768 }
2769 \]
2770 </div>
2771
2772 </div>
2773 </div>
2774 <div style="clear: both"></div>
2775 </div>
2776 </div>
2777
2778 <div class="hgroup">
2779 <div class="hgroup-inline">
2780 <div class="panel">
2781 <p>
2782 String concatenation will implicitly convert one of the values to a string if necessary.
2783 This is similar to Java. The referred function \(tostring\) returns its argument unchanged
2784 if it is a string. Otherwise it will manifest its argument as a JSON value \(j\) and
2785 unparse it as a single line of text. The referred function \(strlen\) returns the number of
2786 unicode characters in the string.
2787 </p>
2788 <p>
2789 The numeric semantics are as follows:
2790 </p>
2791 <ul>
2792 <li>
2793 <b>Arithmetic:</b> Binary <code>*</code>, <code>/</code>, <code>+</code>, <code>-</code>,
2794 <code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>, and unary
2795 <code>+</code> and <code>-</code> operate on numbers and have IEEE double precision
2796 floating point semantics, except that the special states NaN, Infinity raise errors. Note
2797 that <code>+</code> is also overloaded on objects, arrays, and when either argument is a
2798 string. Also, <code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>
2799 are overloaded on strings and on arrays. In both cases the comparison is performed
2800 lexicographically (in case of strings, by unicode codepoint).
2801 </li>
2802 <li>
2803 <b>Bitwise:</b> Operators
2804 <code>&lt;&lt;</code>,
2805 <code>&gt;&gt;</code>,
2806 <code>&amp;</code>,
2807 <code>^</code>,
2808 <code>|</code> and
2809 <code>~</code>
2810 first convert their operands to signed 64 bit integers, then perform the operations in a
2811 standard way, then convert back to IEEE double precision floating point. In shift
2812 operations <code>&lt;&lt;</code>, <code>&gt;&gt;</code>, the right hand value modulo 64 is
2813 interpreted as the shift count. Shifting with a negative shift count raises an error.
2814 </li>
2815 <li>
2816 <b>Standard functions</b>: The following functions have standard mathematical behavior
2817 and operate on IEEE double precision floating point:
2818 <code>std.pow(a, b)</code>,
2819 <code>std.floor(x)</code>,
2820 <code>std.ceil(x)</code>,
2821 <code>std.sqrt(x)</code>,
2822 <code>std.sin(x)</code>,
2823 <code>std.cos(x)</code>,
2824 <code>std.tan(x)</code>,
2825 <code>std.asin(x)</code>,
2826 <code>std.acos(x)</code>,
2827 <code>std.atan(x)</code>,
2828 <code>std.log(x)</code>,
2829 <code>std.exp(x)</code>,
2830 <code>std.mantissa(x)</code>,
2831 <code>std.exponent(x)</code> and
2832 <code>std.modulo(a, b)</code>.
2833 Also, <code>std.codepoint(x)</code> take a single character string,
2834 returning the unicode codepoint as a number, and <code>std.char(x)</code> is its inverse.
2835 </li>
2836 </ul>
2837 <p>
2838 The <code>error</code> operator has no rule because we model errors (both from the language
2839 and user-defined) as stuck execution. The semantics of <code>error</code> are that its
2840 subterm is evaluated to a Jsonnet value. If this is a string, then that is the error that
2841 is raised. Otherwise, it is converted to a string using \(tostring\) like during string
2842 concatenation. The specification does not specify how the error is presented to the user,
2843 and whether or not there is a stack trace. Error messages are meant for human inspection,
2844 and there is therefore no need to standardize them.
2845 </p>
2846 <p>
2847 Finally, the function <code>std.native(x)</code> takes a string and returns a function
2848 configured by the user in a custom execution environment, thus its semantics cannot be
2849 formally described here. The function <code>std.extVar(x)</code> also takes a string and
2850 returns the value bound to that external variable (always a string) at the time the Jsonnet
2851 environment was created.
2852 </p>
2853 </div>
2854 <div style="clear: both"></div>
2855 </div>
2856 </div>
2857
2858 <div class="hgroup">
2859 <div class="hgroup-inline">
2860 <div class="panel">
2861 <h4 id="json_values">JSON Values</h4>
2862 </div>
2863 <div style="clear: both"></div>
2864 </div>
2865 </div>
2866
2867 <div class="hgroup">
2868 <div class="hgroup-inline">
2869 <div class="panel">
2870 <p>
2871 After execution, the resulting Jsonnet value is manifested into a JSON value whose
2872 serialized form is the ultimate output. The Manifestation process removes hidden fields,
2873 checks assertions, and forces array elements and non-hidden object fields. Attempting to
2874 manifest a function raises an error since they do not exist in JSON. JSON values are
2875 formalized below.
2876 </p>
2877 <p>
2878 By abuse of notation, we consider two objects to be equivalent even if their fields are
2879 re-ordered. However this is not true of array elements whose ordering is strict.
2880 </p>
2881 <table>
2882 <tr>
2883 <td><em>j</em></td>
2884 <td>∈</td>
2885 <td><em>JValue</em></td>
2886 <td>=</td>
2887 <td>
2888 <em>Primitive</em> ∪
2889 <em>JObject</em> ∪
2890 <em>JArray</em>
2891 </td>
2892 </tr>
2893 <tr>
2894 <td></td>
2895 <td></td>
2896 <td><em>Primitive</em></td>
2897 <td>::=</td>
2898 <td>
2899 <code>null</code> | <code>true</code> | <code>false</code> | <i>string</i> |
2900 <i>double</i>
2901 </td>
2902 </tr>
2903 <tr>
2904 <td><em>o</em></td>
2905 <td>∈</td>
2906 <td><em>JObject</em></td>
2907 <td>::=</td>
2908 <td>
2909 <code>{</code> { <i>string</i> : <em>j</em> } <code>}</code>
2910 </td>
2911 </tr>
2912 <tr>
2913 <td><em>a</em></td>
2914 <td>∈</td>
2915 <td><em>Array</em></td>
2916 <td>::=</td>
2917 <td>
2918 <code>[</code> { <em>j</em> } <code>]</code>
2919 </td>
2920 </tr>
2921 </table>
2922 <p>Note that <em>JValue</em> ⊂ <em>Value</em>.</p>
2923 </div>
2924 <div style="clear: both"></div>
2925 </div>
2926 </div>
2927
2928 <div class="hgroup">
2929 <div class="hgroup-inline">
2930 <div class="panel">
2931 <h4 id="manifestation">Manifestation</h4>
2932 </div>
2933 <div style="clear: both"></div>
2934 </div>
2935 </div>
2936
2937 <div class="hgroup">
2938 <div class="hgroup-inline">
2939 <div class="panel">
2940 <p>
2941 Manifestation is the conversion of a Jsonnet value into a JSON value. It is represented
2942 with the judgement \(v⇓j\). The process requires executing arbitrary Jsonnet code
2943 fragments, so the two semantic judgements represented by \(↓\) and \(⇓\) are mutually
2944 recursive. Hidden fields are ignored during manifestation. Functions cannot be manifested,
2945 so an error is raised in that case (formalized as stuck execution).
2946 </p>
2947 </div>
2948 <div style="clear: both"></div>
2949 </div>
2950 </div>
2951
2952 <div class="inverse hgroup">
2953 <div class="hgroup-inline">
2954 <div class="panel wide">
2955 <div class="rules">
2956 <div class="sequent-rule">
2957 \[
2958 \rule{manifest-value} {
2959 j ∈ (\{\null, \true, \false\} ∪ String ∪ Number)
2960 } {
2961 j ⇓ j
2962 }
2963 \]
2964 </div>
2965 <div class="sequent-rule">
2966 \[
2967 \rule{manifest-object} {
2968 o = \object{
2969 \assert e''_1 \ldots \assert e''_m,\
2970 f_1 h_1 e_1 \ldots f_n h_n e_n,\
2971 f'_1 :: e'_1 \ldots f'_p :: e'_p,\
2972 }
2973 \\
2974 ∀i∈\{1\ldots m\}: e''_i⟦o/\self,\{\}/\super⟧↓\_
2975 \\
2976 ∀i∈\{1\ldots n\}: e_i⟦o/\self,\{\}/\super⟧↓v_i⇓j_i\ ∧\ h_i ≠ ::
2977 } {
2978 o ⇓ \object{f_1 : j_1 \ldots f_n : j_n}
2979 }
2980 \]
2981 </div>
2982 <div class="sequent-rule">
2983 \[
2984 \rule{manifest-array} {
2985 ∀i∈\{1\ldots n\}: e_i↓v_i⇓j_i
2986 } {
2987 \array{e_1 \ldots e_n} ⇓ \array{j_1 \ldots j_n}
2988 }
2989 \]
2990 </div>
2991 </div>
2992 </div>
2993 <div style="clear: both"></div>
2994 </div>
2995 </div>
2996
2997
2998 <div class="hgroup">
2999 <div class="hgroup-inline">
3000 <div class="panel">
3001 </div>
3002 <div style="clear: both"></div>
3003 </div>
3004 </div>