blob: f695f2288ab7fe24063a71b3f8588543fa06573d [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.5">
<meta name="author" content="2019-08-08 13:15:33 CEST">
<title>N4JS Language Specification</title>
<link rel="stylesheet" href="styles/spec.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<!-- ************* docinfo ******************************************************************* -->
<!-- ************* Favicon ************-->
<link rel="icon" href="images/favicon.ico" />
<!-- ************* Back-to-top JQuery ************* -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<link href="styles/prism.min.css" rel="stylesheet" />
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<!-- ************* Styles ************* -->
<link rel="stylesheet" type="text/css" href="styles/n4jsspec-adoc.css">
<!-- ****************** NavBar ****************** -->
<div id="menubar">
<div class="banner">
<a href="https://www.eclipse.org/n4js/#"><img id="logo" src="images/n4js-logo.png" alt="Eclipse N4JS"></a>
</div>
<ul>
<li><a href="index.html">Index</a></li>
</ul>
</div>
<!-- ************* docinfo ******************************************************************* -->
<style>
.admonitionblock td.icon .icon-todo:before{content:"\f249";color:#f4ee42}
</style>
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>N4JS Language Specification</h1>
<div class="details">
<span id="author" class="author">2019-08-08 13:15:33 CEST</span><br>
<span id="revnumber">version 0.9</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="introduction.html#_introduction">1. Introduction</a>
<ul class="sectlevel2">
<li><a href="introduction.html#_notation">1.1. Notation</a>
<ul class="sectlevel3">
<li><a href="introduction.html#_grammar-notation">1.1.1. Grammar Notation</a></li>
<li><a href="introduction.html#_type-judgments-and-rules-and-constraints-notation">1.1.2. Type Judgments and Rules and Constraints Notation</a>
<ul class="sectlevel4">
<li><a href="introduction.html#_typing-rules-and-judgments">1.1.2.1. Typing Rules and Judgments</a></li>
<li><a href="introduction.html#_types-of-an-element">1.1.2.2. Types of an Element</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="introduction.html#_auxiliary-functions">1.2. Auxiliary Functions</a>
<ul class="sectlevel3">
<li><a href="introduction.html#_binding">1.2.1. Binding</a></li>
<li><a href="introduction.html#_merging-types">1.2.2. Merging Types</a>
<ul class="sectlevel4">
<li><a href="introduction.html#_logic-formulas">1.2.2.1. Logic Formulas</a></li>
</ul>
</li>
<li><a href="introduction.html#_symbols-and-font-convention">1.2.3. Symbols and Font Convention</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="grammar.html#_grammar">2. Grammar</a>
<ul class="sectlevel2">
<li><a href="grammar.html#_lexical-conventions">2.1. Lexical Conventions</a>
<ul class="sectlevel3">
<li><a href="grammar.html#_identifier-names-and-identifiers">2.1.1. Identifier Names and Identifiers</a></li>
<li><a href="grammar.html#_this-keyword">2.1.2. This Keyword</a></li>
<li><a href="grammar.html#_regular-expression-literals">2.1.3. Regular Expression Literals</a></li>
<li><a href="grammar.html#_automatic-semicolon-insertion">2.1.4. Automatic Semicolon Insertion</a></li>
<li><a href="grammar.html#_jsdoc">2.1.5. JSDoc</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="names.html#_names">3. Names</a>
<ul class="sectlevel2">
<li><a href="names.html#_access-control">3.1. Access Control</a></li>
<li><a href="names.html#_accessibility-of-types-top-level-variables-and-function-declarations">3.2. Accessibility of Types, Top-Level Variables and Function Declarations</a>
<ul class="sectlevel3">
<li><a href="names.html#_accessibility-of-members">3.2.1. Accessibility of Members</a></li>
<li><a href="names.html#_valid-names">3.2.2. Valid Names</a></li>
<li><a href="names.html#_qualified-names">3.2.3. Qualified Names</a></li>
<li><a href="names.html#_name-duplicates">3.2.4. Name Duplicates</a>
<ul class="sectlevel4">
<li><a href="names.html#_lexical-environment">3.2.4.1. Lexical Environment</a></li>
<li><a href="names.html#_duplicates-and-shadowing">3.2.4.2. Duplicates and Shadowing</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_types">4. Types</a>
<ul class="sectlevel2">
<li><a href="types.html#_overview">4.1. Overview</a></li>
<li><a href="types.html#_type-expressions">4.2. Type Expressions</a>
<ul class="sectlevel3">
<li><a href="types.html#_syntax">4.2.1. Syntax</a></li>
<li><a href="types.html#_properties">4.2.2. Properties</a></li>
<li><a href="types.html#_semantics">4.2.3. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_type-inference">4.3. Type Inference</a></li>
<li><a href="types.html#_generic-and-parameterized-types">4.4. Generic and Parameterized Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_generic-types">4.4.1. Generic Types</a></li>
<li><a href="types.html#_type-variables">4.4.2. Type Variables</a></li>
<li><a href="types.html#_parameterized-types">4.4.3. Parameterized Types</a></li>
</ul>
</li>
<li><a href="types.html#_primitive-ecmascript-types">4.5. Primitive ECMAScript Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_undefined-type">4.5.1. Undefined Type</a></li>
<li><a href="types.html#_null-type">4.5.2. Null Type</a></li>
<li><a href="types.html#_primitive-boolean-type">4.5.3. Primitive Boolean Type</a></li>
<li><a href="types.html#_primitive-string-type">4.5.4. Primitive String Type</a></li>
<li><a href="types.html#_primitive-number-type">4.5.5. Primitive Number Type</a></li>
<li><a href="types.html#_primitive-type-int">4.5.6. Primitive Type int</a></li>
<li><a href="types.html#_primitive-symbol-type">4.5.7. Primitive Symbol Type</a></li>
</ul>
</li>
<li><a href="types.html#_primitive-n4js-types">4.6. Primitive N4JS Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_any-type">4.6.1. Any Type</a>
<ul class="sectlevel4">
<li><a href="types.html#any-type-semantics">4.6.1.1. Semantics</a></li>
<li><a href="types.html#any-type-type-inference">4.6.1.2. Type Inference</a>
<ul class="sectlevel5">
<li><a href="types.html#_default-type-of-variables">4.6.1.2.1. Default Type of Variables</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_void-type">4.6.2. Void Type</a>
<ul class="sectlevel4">
<li><a href="types.html#void-type-semantics">4.6.2.1. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_unknown-type">4.6.3. Unknown Type</a></li>
<li><a href="types.html#_primitive-pathselector-and-i18nkey">4.6.4. Primitive Pathselector and I18nKey</a>
<ul class="sectlevel4">
<li><a href="types.html#pathselector-semantics">4.6.4.1. Semantics</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_built-in-ecmascript-object-types">4.7. Built-in ECMAScript Object Types</a>
<ul class="sectlevel3">
<li><a href="types.html#ECMAScript-objects-semantics">4.7.1. Semantics</a></li>
<li><a href="types.html#_object-type">4.7.2. Object Type</a></li>
<li><a href="types.html#_function-object-type">4.7.3. Function-Object-Type</a></li>
<li><a href="types.html#_array-object-type">4.7.4. Array Object Type</a></li>
<li><a href="types.html#_string-object-type">4.7.5. String Object Type</a></li>
<li><a href="types.html#_boolean-object-type">4.7.6. Boolean Object Type</a></li>
<li><a href="types.html#_number-object-type">4.7.7. Number Object Type</a></li>
<li><a href="types.html#_global-object-type">4.7.8. Global Object Type</a></li>
<li><a href="types.html#_symbol">4.7.9. Symbol</a></li>
<li><a href="types.html#_promise">4.7.10. Promise</a></li>
<li><a href="types.html#_iterator-interface">4.7.11. Iterator Interface</a></li>
<li><a href="types.html#_iterable-interface">4.7.12. Iterable Interface</a></li>
</ul>
</li>
<li><a href="types.html#_built-in-n4js-types">4.8. Built-In N4JS Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_n4object">4.8.1. N4Object</a>
<ul class="sectlevel4">
<li><a href="types.html#N4Object-semantics">4.8.1.1. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_n4class">4.8.2. N4Class</a></li>
<li><a href="types.html#IterableN">4.8.3. IterableN</a></li>
</ul>
</li>
<li><a href="types.html#_type-modifiers">4.9. Type Modifiers</a>
<ul class="sectlevel3">
<li><a href="types.html#Type_Modifiers_Dynamic">4.9.1. Dynamic</a></li>
<li><a href="types.html#_optional-return-types">4.9.2. Optional Return Types</a></li>
</ul>
</li>
<li><a href="types.html#_union-and-intersection-type-composed-types">4.10. Union and Intersection Type (Composed Types)</a>
<ul class="sectlevel3">
<li><a href="types.html#_union-type">4.10.1. Union Type</a>
<ul class="sectlevel4">
<li><a href="types.html#union-type-syntax">4.10.1.1. Syntax</a></li>
<li><a href="types.html#union-type-semantics">4.10.1.2. Semantics</a></li>
<li><a href="types.html#_warnings">4.10.1.3. Warnings</a></li>
</ul>
</li>
<li><a href="types.html#_intersection-type">4.10.2. Intersection Type</a>
<ul class="sectlevel4">
<li><a href="types.html#intersection-type-syntax">4.10.2.1. Syntax</a></li>
<li><a href="types.html#intersection-type-semantics">4.10.2.2. Semantics</a></li>
<li><a href="types.html#_warnings-2">4.10.2.3. Warnings</a></li>
</ul>
</li>
<li><a href="types.html#_composed-types-in-wildcards">4.10.3. Composed Types in Wildcards</a></li>
<li><a href="types.html#_property-access-for-composed-types">4.10.4. Property Access for Composed Types</a>
<ul class="sectlevel4">
<li><a href="types.html#_properties-of-union-type">4.10.4.1. Properties of Union Type</a>
<ul class="sectlevel5">
<li><a href="types.html#_remarks-on-union-type-s-members">4.10.4.1.1. Remarks on union type’s members:</a></li>
</ul>
</li>
<li><a href="types.html#_properties-of-intersection-type">4.10.4.2. Properties of Intersection Type</a>
<ul class="sectlevel5">
<li><a href="types.html#_remarks-on-intersection-type-s-methods">4.10.4.2.1. Remarks on intersection type’s methods:</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_constructor-and-classifier-type">4.11. Constructor and Classifier Type</a>
<ul class="sectlevel3">
<li><a href="types.html#_syntax-3">4.11.1. Syntax</a></li>
<li><a href="types.html#_semantics-2">4.11.2. Semantics</a></li>
<li><a href="types.html#_constructors-and-prototypes-in-ecmascript-2015">4.11.3. Constructors and Prototypes in ECMAScript 2015</a></li>
</ul>
</li>
<li><a href="types.html#_this-type">4.12. This Type</a>
<ul class="sectlevel3">
<li><a href="types.html#this-type-syntax">4.12.1. Syntax</a></li>
<li><a href="types.html#this-keyword-semantics">4.12.2. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_enums">4.13. Enums</a>
<ul class="sectlevel3">
<li><a href="types.html#_enums-n4js">4.13.1. Enums (N4JS)</a>
<ul class="sectlevel4">
<li><a href="types.html#enums-syntax">4.13.1.1. Syntax</a></li>
<li><a href="types.html#enums-semantics">4.13.1.2. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_string-based-enums">4.13.2. String-Based Enums</a></li>
</ul>
</li>
<li><a href="types.html#_short-hand-syntax">4.14. Short-Hand Syntax</a>
<ul class="sectlevel3">
<li><a href="types.html#_array-short-hand-syntax">4.14.1. Array Short-Hand Syntax</a></li>
<li><a href="types.html#_iterablen-short-hand-syntax">4.14.2. IterableN Short-Hand Syntax</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_classifiers">5. Classifiers</a>
<ul class="sectlevel2">
<li><a href="classifiers.html#_n4js-specific-classifiers">5.1. N4JS Specific Classifiers</a>
<ul class="sectlevel3">
<li><a href="classifiers.html#_properties-2">5.1.1. Properties</a></li>
<li><a href="classifiers.html#_common-semantics-of-classifiers">5.1.2. Common Semantics of Classifiers</a></li>
<li><a href="classifiers.html#_classes">5.1.3. Classes</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_definition-of-classes">5.1.3.1. Definition of Classes</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#class-syntax">5.1.3.1.1. Syntax</a></li>
<li><a href="classifiers.html#class-properties">5.1.3.1.2. Properties</a></li>
<li><a href="classifiers.html#class-type-inference">5.1.3.1.3. Type Inference</a></li>
</ul>
</li>
<li><a href="classifiers.html#class-semantics">5.1.3.2. Semantics</a></li>
<li><a href="classifiers.html#_final-modifier">5.1.3.3. Final Modifier</a></li>
<li><a href="classifiers.html#_abstract-classes">5.1.3.4. Abstract Classes</a></li>
<li><a href="classifiers.html#_non-instantiable-classes">5.1.3.5. Non-Instantiable Classes</a></li>
<li><a href="classifiers.html#_superclass">5.1.3.6. Superclass</a></li>
</ul>
</li>
<li><a href="classifiers.html#_interfaces">5.1.4. Interfaces</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_definition-of-interfaces">5.1.4.1. Definition of Interfaces</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#interfaces-syntax">5.1.4.1.1. Syntax</a></li>
<li><a href="classifiers.html#interfaces-properties">5.1.4.1.2. Properties</a></li>
<li><a href="classifiers.html#interfaces-type-inference">5.1.4.1.3. Type Inference</a></li>
<li><a href="classifiers.html#interfaces-semantics">5.1.4.1.4. Semantics</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_generic-classifiers">5.1.5. Generic Classifiers</a></li>
<li><a href="classifiers.html#sec:definition-site-variance">5.1.6. Definition-Site Variance</a></li>
</ul>
</li>
<li><a href="classifiers.html#_members">5.2. Members</a>
<ul class="sectlevel3">
<li><a href="classifiers.html#_syntax-4">5.2.1. Syntax</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_properties-3">5.2.1.1. Properties</a></li>
</ul>
</li>
<li><a href="classifiers.html#_semantics-3">5.2.2. Semantics</a></li>
<li><a href="classifiers.html#_methods">5.2.3. Methods</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_syntax-5">5.2.3.1. Syntax</a></li>
<li><a href="classifiers.html#_properties-4">5.2.3.2. Properties</a></li>
<li><a href="classifiers.html#_semantics-4">5.2.3.3. Semantics</a></li>
<li><a href="classifiers.html#_final-methods">5.2.3.4. Final Methods</a></li>
<li><a href="classifiers.html#_abstract-methods">5.2.3.5. Abstract Methods</a></li>
<li><a href="classifiers.html#_generic-methods">5.2.3.6. Generic Methods</a></li>
</ul>
</li>
<li><a href="classifiers.html#_default-methods-in-interfaces">5.2.4. Default Methods in Interfaces</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_asynchronous-methods">5.2.4.1. Asynchronous Methods</a></li>
</ul>
</li>
<li><a href="classifiers.html#_constructors">5.2.5. Constructors</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_structural-this-type-in-constructor">5.2.5.1. Structural This Type in Constructor</a></li>
<li><a href="classifiers.html#spec-constructor">5.2.5.2. @Spec Constructor</a></li>
<li><a href="classifiers.html#_callable-constructors">5.2.5.3. Callable Constructors</a></li>
<li><a href="classifiers.html#_covariant-constructors">5.2.5.4. Covariant Constructors</a></li>
</ul>
</li>
<li><a href="classifiers.html#_data-fields">5.2.6. Data Fields</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#data-fields-syntax">5.2.6.1. Syntax</a></li>
<li><a href="classifiers.html#data-fields-properties">5.2.6.2. Properties</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#data-fields-semantics">5.2.6.2.1. Semantics</a></li>
<li><a href="classifiers.html#data-fields-type-inference">5.2.6.2.2. Type Inference</a></li>
</ul>
</li>
<li><a href="classifiers.html#_assignment-modifiers">5.2.6.3. Assignment Modifiers</a></li>
<li><a href="classifiers.html#_field-accessors-getter-setter">5.2.6.4. Field Accessors (Getter/Setter)</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#field-acessors-syntax">5.2.6.4.1. Syntax</a></li>
<li><a href="classifiers.html#field-acessors-properties">5.2.6.4.2. Properties</a></li>
<li><a href="classifiers.html#field-accessors-semantics">5.2.6.4.3. Semantics</a></li>
</ul>
</li>
<li><a href="classifiers.html#optional-fields">5.2.6.5. Optional Fields</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#_syntax-6">5.2.6.5.1. Syntax</a></li>
<li><a href="classifiers.html#_semantics-5">5.2.6.5.2. Semantics</a></li>
<li><a href="classifiers.html#_background">5.2.6.5.3. Background</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_static-members">5.2.7. Static Members</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_access-from-and-to-static-members">5.2.7.1. Access From and To Static Members</a></li>
<li><a href="classifiers.html#_generic-static-methods">5.2.7.2. Generic static methods</a></li>
<li><a href="classifiers.html#_static-members-of-interfaces">5.2.7.3. Static Members of Interfaces</a></li>
</ul>
</li>
<li><a href="classifiers.html#_redefinition-of-members">5.2.8. Redefinition of Members</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_overriding-of-members">5.2.8.1. Overriding of Members</a></li>
<li><a href="classifiers.html#_implementation-of-members">5.2.8.2. Implementation of Members</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#_member-consumption">5.2.8.2.1. Member Consumption</a></li>
<li><a href="classifiers.html#_member-implementation">5.2.8.2.2. Member Implementation</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_structural-typing">5.3. Structural Typing</a>
<ul class="sectlevel3">
<li><a href="classifiers.html#_syntax-7">5.3.1. Syntax</a></li>
<li><a href="classifiers.html#_definition-site-structural-typing">5.3.2. Definition Site Structural Typing</a></li>
<li><a href="classifiers.html#_use-site-structural-typing">5.3.3. Use-Site Structural Typing</a></li>
<li><a href="classifiers.html#structural-readWriteInit-field-typing">5.3.4. Structural Read-only, Write-only and Initializer Field Typing</a></li>
<li><a href="classifiers.html#_public-setter-annotated-with-code-providesinitializer-code">5.3.5. Public Setter Annotated With <code>ProvidesInitializer</code></a></li>
<li><a href="classifiers.html#_structural-types-with-optional-fields">5.3.6. Structural Types With Optional Fields</a></li>
<li><a href="classifiers.html#_structural-types-with-access-modifier">5.3.7. Structural Types With Access Modifier</a></li>
<li><a href="classifiers.html#_structural-types-with-additional-members">5.3.8. Structural Types With Additional Members</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_syntax-8">5.3.8.1. Syntax</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#_semantics-6">5.3.8.1.1. Semantics</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_functions">6. Functions</a>
<ul class="sectlevel2">
<li><a href="functions.html#_function-type">6.1. Function Type</a>
<ul class="sectlevel3">
<li><a href="functions.html#_properties-5">6.1.1. Properties</a></li>
<li><a href="functions.html#function-type-inference">6.1.2. Type Inference</a></li>
<li><a href="functions.html#_autoboxing-of-function-type">6.1.3. Autoboxing of Function Type</a></li>
<li><a href="functions.html#_arguments-object">6.1.4. Arguments Object</a></li>
</ul>
</li>
<li><a href="functions.html#_ecmascript-5-function-definition">6.2. ECMAScript 5 Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_function-declaration">6.2.1. Function Declaration</a>
<ul class="sectlevel4">
<li><a href="functions.html#_syntax-9">6.2.1.1. Syntax</a></li>
<li><a href="functions.html#_semantics-8">6.2.1.2. Semantics</a></li>
</ul>
</li>
<li><a href="functions.html#_function-expression">6.2.2. Function Expression</a>
<ul class="sectlevel4">
<li><a href="functions.html#function-expression-syntax">6.2.2.1. Syntax</a></li>
<li><a href="functions.html#_semantics-and-type-inference">6.2.2.2. Semantics and Type Inference</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_ecmascript-2015-function-definition">6.3. ECMAScript 2015 Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_formal-parameters">6.3.1. Formal Parameters</a>
<ul class="sectlevel4">
<li><a href="functions.html#Type_Modifiers_Optional">6.3.1.1. Optional Parameters</a></li>
<li><a href="functions.html#Type_Modifiers_Default">6.3.1.2. Default Parameters</a></li>
<li><a href="functions.html#Type_Modifiers_Variadic">6.3.1.3. Variadic</a></li>
</ul>
</li>
<li><a href="functions.html#_generator-functions">6.3.2. Generator Functions</a>
<ul class="sectlevel4">
<li><a href="functions.html#generator-functions-syntax">6.3.2.1. Syntax</a></li>
<li><a href="functions.html#generator-functions-semantics">6.3.2.2. Semantics</a></li>
<li><a href="functions.html#_generator-arrow-functions">6.3.2.3. Generator Arrow Functions</a></li>
</ul>
</li>
<li><a href="functions.html#_arrow-function-expression">6.3.3. Arrow Function Expression</a>
<ul class="sectlevel4">
<li><a href="functions.html#arrow-function-expression-syntax">6.3.3.1. Syntax</a></li>
<li><a href="functions.html#arrow-function-expression-semantics-and-type-inference">6.3.3.2. Semantics and Type Inference</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_ecmascript-proposals-function-definition">6.4. ECMAScript Proposals Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_asynchronous-functions">6.4.1. Asynchronous Functions</a>
<ul class="sectlevel4">
<li><a href="functions.html#asynchronous-functions-syntax">6.4.1.1. Syntax</a></li>
<li><a href="functions.html#asynchronous-functions-semantics">6.4.1.2. Semantics</a></li>
<li><a href="functions.html#_asynchronous-arrow-functions">6.4.1.3. Asynchronous Arrow Functions</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_n4js-extended-function-definition">6.5. N4JS Extended Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_generic-functions">6.5.1. Generic Functions</a></li>
<li><a href="functions.html#_promisifiable-functions">6.5.2. Promisifiable Functions</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_conversions-and-reflection">7. Conversions and Reflection</a>
<ul class="sectlevel2">
<li><a href="conversions_and_reflection.html#_autoboxing-and-coercing">7.1. Autoboxing and Coercing</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_coercing">7.1.1. Coercing</a></li>
<li><a href="conversions_and_reflection.html#_autoboxing-of-primitives">7.1.2. Autoboxing of Primitives</a></li>
<li><a href="conversions_and_reflection.html#_autoboxing-of-function-expressions-and-declarations">7.1.3. Autoboxing of Function Expressions and Declarations</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_auto-conversion-of-objects">7.2. Auto-Conversion of Objects</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_auto-conversion-of-class-instances">7.2.1. Auto-Conversion of Class Instances</a>
<ul class="sectlevel4">
<li><a href="conversions_and_reflection.html#_auto-conversion-of-interface-instances">7.2.1.1. Auto-Conversion of Interface Instances</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_auto-conversion-of-enum-literals">7.2.2. Auto-Conversion of Enum Literals</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_type-cast-and-type-check">7.3. Type Cast and Type Check</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_type-cast">7.3.1. Type Cast</a></li>
<li><a href="conversions_and_reflection.html#_type-check">7.3.2. Type Check</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_reflection-meta-information">7.4. Reflection meta-information</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_reflection-for-classes">7.4.1. Reflection for Classes</a></li>
<li><a href="conversions_and_reflection.html#_reflection-for-interfaces">7.4.2. Reflection for Interfaces</a></li>
<li><a href="conversions_and_reflection.html#_reflection-for-enumerations">7.4.3. Reflection for Enumerations</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_conversion-of-primitive-types">7.5. Conversion of primitive types</a></li>
</ul>
</li>
<li><a href="#_expressions">8. Expressions</a>
<ul class="sectlevel2">
<li><a href="#_ecmascript-5-expressions">8.1. ECMAScript 5 Expressions</a>
<ul class="sectlevel3">
<li><a href="#_the-this-literal">8.1.1. The this Literal</a></li>
<li><a href="#_identifier">8.1.2. Identifier</a></li>
<li><a href="#_literals">8.1.3. Literals</a>
<ul class="sectlevel4">
<li><a href="#_integer-literals">8.1.3.1. Integer Literals</a></li>
</ul>
</li>
<li><a href="#_array-literal">8.1.4. Array Literal</a></li>
<li><a href="#_object-literal">8.1.5. Object Literal</a>
<ul class="sectlevel4">
<li><a href="#_properties-6">8.1.5.1. Properties</a></li>
<li><a href="#_scoping-and-linking">8.1.5.2. Scoping and linking</a></li>
</ul>
</li>
<li><a href="#_parenthesized-expression-and-grouping-operator">8.1.6. Parenthesized Expression and Grouping Operator</a></li>
<li><a href="#_property-accessors">8.1.7. Property Accessors</a>
<ul class="sectlevel4">
<li><a href="#properties-1">8.1.7.1. Properties</a></li>
</ul>
</li>
<li><a href="#_new-expression">8.1.8. New Expression</a></li>
<li><a href="#_function-expression-2">8.1.9. Function Expression</a></li>
<li><a href="#_function-calls">8.1.10. Function Calls</a></li>
<li><a href="#_postfix-expression">8.1.11. Postfix Expression</a></li>
<li><a href="#_unary-expression">8.1.12. Unary Expression</a></li>
<li><a href="#_multiplicative-expression">8.1.13. Multiplicative Expression</a></li>
<li><a href="#_additive-expression">8.1.14. Additive Expression</a>
<ul class="sectlevel4">
<li><a href="#type-inference-10">8.1.14.1. Type Inference</a></li>
</ul>
</li>
<li><a href="#_bitwise-shift-expression">8.1.15. Bitwise Shift Expression</a></li>
<li><a href="#_relational-expression">8.1.16. Relational Expression</a></li>
<li><a href="#_equality-expression">8.1.17. Equality Expression</a></li>
<li><a href="#_binary-bitwise-expression">8.1.18. Binary Bitwise Expression</a></li>
<li><a href="#_binary-logical-expression">8.1.19. Binary Logical Expression</a></li>
<li><a href="#_conditional-expression">8.1.20. Conditional Expression</a></li>
<li><a href="#_assignment-expression">8.1.21. Assignment Expression</a></li>
<li><a href="#_comma-expression">8.1.22. Comma Expression</a></li>
</ul>
</li>
<li><a href="#_ecmascript-6-expressions">8.2. ECMAScript 6 Expressions</a>
<ul class="sectlevel3">
<li><a href="#_the-super-keyword">8.2.1. The super Keyword</a></li>
</ul>
</li>
<li><a href="#_ecmascript-7-expressions">8.3. ECMAScript 7 Expressions</a>
<ul class="sectlevel3">
<li><a href="#_await-expression">8.3.1. Await Expression</a></li>
</ul>
</li>
<li><a href="#_n4js-specific-expressions">8.4. N4JS Specific Expressions</a>
<ul class="sectlevel3">
<li><a href="#_class-expression">8.4.1. Class Expression</a></li>
<li><a href="#_cast-as-expression">8.4.2. Cast (As) Expression</a>
<ul class="sectlevel4">
<li><a href="#cast-as-expression-semantics-type-inference">8.4.2.1. Semantics and Type Inference</a></li>
</ul>
</li>
<li><a href="#Import_Calls">8.4.3. Import Calls</a></li>
</ul>
</li>
<li><a href="#compile-time-expressions">8.5. Compile-Time Expressions</a></li>
</ul>
</li>
<li><a href="statements.html#_statements">9. Statements</a>
<ul class="sectlevel2">
<li><a href="statements.html#_ecmascript-5-statements">9.1. ECMAScript 5 Statements</a>
<ul class="sectlevel3">
<li><a href="statements.html#_function-or-field-accessor-bodies">9.1.1. Function or Field Accessor Bodies</a></li>
<li><a href="statements.html#_variable-statement">9.1.2. Variable Statement</a></li>
<li><a href="statements.html#_if-statement">9.1.3. If Statement</a></li>
<li><a href="statements.html#_iteration-statements">9.1.4. Iteration Statements</a></li>
<li><a href="statements.html#_return-statement">9.1.5. Return Statement</a></li>
<li><a href="statements.html#_with-statement">9.1.6. With Statement</a></li>
<li><a href="statements.html#_switch-statement">9.1.7. Switch Statement</a></li>
<li><a href="statements.html#_throw-try-and-catch-statements">9.1.8. Throw, Try, and Catch Statements</a></li>
<li><a href="statements.html#_debugger-statement">9.1.9. Debugger Statement</a></li>
</ul>
</li>
<li><a href="statements.html#_ecmascript-6-statements">9.2. ECMAScript 6 Statements</a>
<ul class="sectlevel3">
<li><a href="statements.html#_let">9.2.1. Let</a></li>
<li><a href="statements.html#_const">9.2.2. Const</a></li>
<li><a href="statements.html#_for-of-statement">9.2.3. <code>for &#8230;&#8203; of</code> statement</a></li>
<li><a href="statements.html#_import-statement">9.2.4. Import Statement</a>
<ul class="sectlevel4">
<li><a href="statements.html#Dynamic_Imports">9.2.4.1. Dynamic Imports</a></li>
<li><a href="statements.html#_immutabilaty-of-imports">9.2.4.2. Immutabilaty of Imports</a></li>
</ul>
</li>
<li><a href="statements.html#_export-statement">9.2.5. Export Statement</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="annotations.html#_annotations">10. Annotations</a>
<ul class="sectlevel2">
<li><a href="annotations.html#_introduction-2">10.1. Introduction</a>
<ul class="sectlevel3">
<li><a href="annotations.html#_syntax-13">10.1.1. Syntax</a></li>
<li><a href="annotations.html#_properties-7">10.1.2. Properties</a></li>
<li><a href="annotations.html#_element-specific-annotations">10.1.3. Element-Specific Annotations</a></li>
<li><a href="annotations.html#_general-annotations">10.1.4. General Annotations</a>
<ul class="sectlevel4">
<li><a href="annotations.html#_idebug">10.1.4.1. IDEBUG</a></li>
</ul>
</li>
<li><a href="annotations.html#idebug-syntax">10.1.5. Syntax</a>
<ul class="sectlevel4">
<li><a href="annotations.html#_semantics-11">10.1.5.1. Semantics</a></li>
<li><a href="annotations.html#_suppress-warnings">10.1.5.2. Suppress Warnings</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="annotations.html#_declaration-of-annotations">10.2. Declaration of Annotations</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_extended-fetaures">11. Extended Fetaures</a>
<ul class="sectlevel2">
<li><a href="extended_fetaures.html#_array-and-object-destructuring">11.1. Array and Object Destructuring</a>
<ul class="sectlevel3">
<li><a href="extended_fetaures.html#_syntax-14">11.1.1. Syntax</a></li>
<li><a href="extended_fetaures.html#_semantics-12">11.1.2. Semantics</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_dependency-injection">11.2. Dependency Injection</a>
<ul class="sectlevel3">
<li><a href="extended_fetaures.html#_di-components-and-injectors">11.2.1. DI Components and Injectors</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_dicomponent-relations">11.2.1.1. DIComponent Relations</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_binders-and-bindings">11.2.2. Binders and Bindings</a></li>
<li><a href="extended_fetaures.html#_injection-points">11.2.3. Injection Points</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_field-injection">11.2.3.1. Field Injection</a></li>
<li><a href="extended_fetaures.html#_constructor-injection">11.2.3.2. Constructor Injection</a></li>
<li><a href="extended_fetaures.html#_method-injection">11.2.3.3. Method Injection</a>
<ul class="sectlevel5">
<li><a href="extended_fetaures.html#_provider">11.2.3.3.1. Provider</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="extended_fetaures.html#_n4js-di-life-cycle-and-scopes">11.2.4. N4JS DI Life Cycle and Scopes</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_injection-cylces">11.2.4.1. Injection Cylces</a></li>
<li><a href="extended_fetaures.html#_default-scope">11.2.4.2. Default Scope</a></li>
<li><a href="extended_fetaures.html#_singleton-scope">11.2.4.3. Singleton Scope</a></li>
<li><a href="extended_fetaures.html#_per-injection-chain-singleton">11.2.4.4. Per Injection Chain Singleton</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_validation-of-callsites-targeting-n4injector-methods">11.2.5. Validation of callsites targeting N4Injector methods</a></li>
<li><a href="extended_fetaures.html#_n4js-di-annotations">11.2.6. N4JS DI Annotations</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_n4js-di-generateinjector">11.2.6.1. N4JS DI @GenerateInjector</a></li>
<li><a href="extended_fetaures.html#_n4js-di-withparentinjector">11.2.6.2. N4JS DI @WithParentInjector</a></li>
<li><a href="extended_fetaures.html#_n4js-di-usebinder">11.2.6.3. N4JS DI @UseBinder</a></li>
<li><a href="extended_fetaures.html#_n4js-di-binder">11.2.6.4. N4JS DI @Binder</a></li>
<li><a href="extended_fetaures.html#_n4js-di-bind">11.2.6.5. N4JS DI @Bind</a></li>
<li><a href="extended_fetaures.html#_n4js-di-provides">11.2.6.6. N4JS DI @Provides</a></li>
<li><a href="extended_fetaures.html#_n4js-di-inject">11.2.6.7. N4JS DI @Inject</a></li>
<li><a href="extended_fetaures.html#_n4js-di-singleton">11.2.6.8. N4JS DI @Singleton</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="extended_fetaures.html#_test-support">11.3. Test Support</a></li>
<li><a href="extended_fetaures.html#_polyfill-definitions">11.4. Polyfill Definitions</a>
<ul class="sectlevel3">
<li><a href="extended_fetaures.html#_runtime-polyfill-definitions">11.4.1. Runtime Polyfill Definitions</a></li>
<li><a href="extended_fetaures.html#_static-polyfill-definitions">11.4.2. Static Polyfill Definitions</a></li>
<li><a href="extended_fetaures.html#_transpiling-static-polyfilled-classes">11.4.3. Transpiling static polyfilled classes</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="components.html#_components">12. Components</a>
<ul class="sectlevel2">
<li><a href="components.html#_overview-2">12.1. Overview</a></li>
<li><a href="components.html#Component_Types">12.2. Component Types</a>
<ul class="sectlevel3">
<li><a href="components.html#_libraries">12.2.1. Libraries</a></li>
<li><a href="components.html#_runtime-environment-and-runtime-libraries">12.2.2. Runtime Environment and Runtime Libraries</a></li>
<li><a href="components.html#_tests">12.2.3. Tests</a></li>
<li><a href="components.html#_type-definitions">12.2.4. Type Definitions</a></li>
</ul>
</li>
<li><a href="components.html#package-json">12.3. Package.json File</a>
<ul class="sectlevel3">
<li><a href="components.html#_basic-properties">12.3.1. Basic Properties</a></li>
<li><a href="components.html#_n4js-properties">12.3.2. N4JS Properties</a></li>
<li><a href="components.html#_constraints">12.3.3. Constraints</a></li>
</ul>
</li>
<li><a href="components.html#_support-for-npm-scopes">12.4. Support for NPM Scopes</a></li>
<li><a href="components.html#sec:N4JS-Type-Definitions">12.5. N4JS Type Definitions</a>
<ul class="sectlevel3">
<li><a href="components.html#_specify-type-definition">12.5.1. Specify Type Definition</a></li>
<li><a href="components.html#_name-conventions">12.5.2. Name Conventions</a></li>
<li><a href="components.html#_version-conventions">12.5.3. Version Conventions</a>
<ul class="sectlevel4">
<li><a href="components.html#_define-a-new-type-definition-package">12.5.3.1. Define a New Type Definition Package</a></li>
<li><a href="components.html#_using-a-type-definition-package">12.5.3.2. Using a Type Definition Package</a></li>
<li><a href="components.html#_rational">12.5.3.3. Rational</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="components.html#_modules">12.6. Modules</a></li>
<li><a href="components.html#_api-and-implementation-component">12.7. API and Implementation Component</a>
<ul class="sectlevel3">
<li><a href="components.html#_execution-of-api-and-implementation-components">12.7.1. Execution of API and Implementation Components</a></li>
<li><a href="components.html#_api-and-implementation-with-di">12.7.2. API and Implementation With DI</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="plainjs.html#_plainjs">13. PlainJS</a>
<ul class="sectlevel2">
<li><a href="plainjs.html#_type-inference-and-validation-for-plain-js">13.1. Type Inference and Validation for Plain JS</a></li>
<li><a href="plainjs.html#_external-declarations">13.2. External Declarations</a>
<ul class="sectlevel3">
<li><a href="plainjs.html#_declaring-externals">13.2.1. Declaring externals</a></li>
<li><a href="plainjs.html#_instantiating-external-classes">13.2.2. Instantiating external classes</a></li>
<li><a href="plainjs.html#_implementation-of-external-declarations">13.2.3. Implementation of External Declarations</a></li>
<li><a href="plainjs.html#_example">13.2.4. Example</a></li>
</ul>
</li>
<li><a href="plainjs.html#_global-definitions">13.3. Global Definitions</a></li>
<li><a href="plainjs.html#_runtime-definitions">13.4. Runtime Definitions</a></li>
<li><a href="plainjs.html#_applying-polyfills">13.5. Applying Polyfills</a></li>
</ul>
</li>
<li><a href="jsdoc.html#_jsdoc-2">14. JSDoc</a>
<ul class="sectlevel2">
<li><a href="jsdoc.html#_general-n4jsdoc-features">14.1. General N4JSDoc Features</a>
<ul class="sectlevel3">
<li><a href="jsdoc.html#_provided-inline-tags">14.1.1. Provided Inline Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#jsdoc_tag__code">14.1.1.1. @code</a></li>
<li><a href="jsdoc.html#jsdoc_tag__link">14.1.1.2. @link</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="jsdoc.html#_n4jsdoc-for-user-projects">14.2. N4JSdoc for User Projects</a>
<ul class="sectlevel3">
<li><a href="jsdoc.html#_standard-tags">14.2.1. Standard Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#_-author">14.2.1.1. @author</a></li>
<li><a href="jsdoc.html#jsdoc_tag_param">14.2.1.2. @param</a></li>
<li><a href="jsdoc.html#jsdoc_tag_return">14.2.1.3. @return</a></li>
</ul>
</li>
<li><a href="jsdoc.html#_test-related-tags">14.2.2. Test Related Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#jsdoc_tag__testee">14.2.2.1. @testee</a></li>
<li><a href="jsdoc.html#jsdoc_tag__testeeFromType">14.2.2.2. @testeeFromType</a></li>
<li><a href="jsdoc.html#_testeeType_and__testeeMember">14.2.2.3. @testeeType and @testeeMember</a></li>
<li><a href="jsdoc.html#jsdoc_tag_reqid_in_Tests">14.2.2.4. @reqid in Tests</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="jsdoc.html#_n4jsdoc-for-api-and-implementation-projects">14.3. N4JSDoc for API and Implementation Projects</a>
<ul class="sectlevel3">
<li><a href="jsdoc.html#jsdoc_tag__apiNote">14.3.1. @apiNote</a></li>
<li><a href="jsdoc.html#API_Project_Tags">14.3.2. API Project Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#jsdoc_tag_apiState">14.3.2.1. @apiState</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="jsx.html#_jsx">15. JSX</a>
<ul class="sectlevel2">
<li><a href="jsx.html#_jsx-support">15.1. JSX Support</a></li>
<li><a href="jsx.html#_jsx-backend">15.2. JSX Backend</a></li>
</ul>
</li>
<li><a href="grammars.html#_grammars">16. Grammars</a>
<ul class="sectlevel2">
<li><a href="grammars.html#_type-expressions-grammar">16.1. Type Expressions Grammar</a></li>
<li><a href="grammars.html#_n4js-language-grammar">16.2. N4JS Language Grammar</a></li>
</ul>
</li>
<li><a href="jsobjects.html#_jsobjects">17. JSObjects</a>
<ul class="sectlevel2">
<li><a href="jsobjects.html#_object">17.1. Object</a></li>
<li><a href="jsobjects.html#_string">17.2. String</a></li>
<li><a href="jsobjects.html#_boolean">17.3. Boolean</a></li>
<li><a href="jsobjects.html#_number">17.4. Number</a>
<ul class="sectlevel3">
<li><a href="jsobjects.html#_static-attributes">17.4.1. Static Attributes</a></li>
</ul>
</li>
<li><a href="jsobjects.html#function">17.5. Function</a></li>
<li><a href="jsobjects.html#_error">17.6. Error</a></li>
<li><a href="jsobjects.html#_array">17.7. Array</a></li>
<li><a href="jsobjects.html#_date">17.8. Date</a></li>
<li><a href="jsobjects.html#_math">17.9. Math</a>
<ul class="sectlevel3">
<li><a href="jsobjects.html#static-attributes-1">17.9.1. Static Attributes</a></li>
</ul>
</li>
<li><a href="jsobjects.html#_regexp">17.10. RegExp</a></li>
<li><a href="jsobjects.html#_json">17.11. JSON</a></li>
</ul>
</li>
<li><a href="n4js_objects.html#_n4js-objects">18. N4JS Objects</a>
<ul class="sectlevel2">
<li><a href="n4js_objects.html#_reflection-model">18.1. Reflection Model</a></li>
<li><a href="n4js_objects.html#_error-types">18.2. Error Types</a>
<ul class="sectlevel3">
<li><a href="n4js_objects.html#_n4apinotimplemented">18.2.1. N4ApiNotImplemented</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="appendix_a_acronyms.html#_acronyms">Appendix A: Acronyms</a></li>
<li><a href="appendix_b_license.html#sec:License">Appendix B: License</a></li>
<li><a href="appendix_c_bibliography.html#_bibliography">Appendix C: Bibliography</a></li>
</ul>
</div>
</div>
<div id="content"><div class="sect1">
<h2 id="_expressions"><a class="anchor" href="#_expressions"></a><a class="link" href="#_expressions">8. Expressions</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>For all expressions, we define the following pseudo properties:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>containingExpression</code> </dt>
<dd>
<p>The parent expression, in which an expression is contained, may be null.</p>
</dd>
<dt class="hdlist1"><code>containingStatement</code> </dt>
<dd>
<p>The statement in which the expression is (indirectly) contained.</p>
</dd>
<dt class="hdlist1"><code>containingFunctionOrAccessor</code> </dt>
<dd>
<p>The function, method, getter or setter in which the expression is (indirectly) contained, may be null.</p>
</dd>
<dt class="hdlist1"><code>containingClass</code> </dt>
<dd>
<p>The class in which the expression is (indirectly) contained, may be null.</p>
</dd>
<dt class="hdlist1"><code>probableThisTarget</code> </dt>
<dd>
<p>The potential target of a this keyword binding, this is not necessarily the containing class or object literal.
In case of instance methods of a class <code>T</code>, this usually is the classifier <code>T</code>; in case of static methods, it is the classifier type <code>type{type}</code>.</p>
</dd>
<dt class="hdlist1"><code>container</code> </dt>
<dd>
<p>The direct owner of the expression.
z</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>The expressions and statements are ordered, describing first the constructs available in the 5th edition of ECMA-262, referred to as [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a</a>] in the following.
It is worth noting that the grammar snippets already use newer constructs in some cases.</p>
</div>
<div class="sect2 language-n4js">
<h3 id="_ecmascript-5-expressions"><a class="anchor" href="#_ecmascript-5-expressions"></a><a class="link" href="#_ecmascript-5-expressions">8.1. ECMAScript 5 Expressions</a></h3>
<div class="paragraph">
<p>N4JS supports the same expressions as ECMAScript.
The semantics are described in [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11)</a>].
In N4JS, some expressions are extended for supporting the declaration of types, annotations, or parameterized usages.
These extensions and type-related aspects as well as specific N4JS constraints are described in this section.</p>
</div>
<div class="paragraph">
<p>Some operators come in different ’flavors’, that is as binary operator, unary pre- or postfix operators, or assignment operators.
For these operators, type constraints are only defined for the binary operator version and the other variants are deduced to that binary version.
E.g., <code>++</code> and <code>+=</code> are deduced to <code>+</code> (and simple assignment).</p>
</div>
<div class="sect3">
<h4 id="_the-this-literal"><a class="anchor" href="#_the-this-literal"></a><a class="link" href="#_the-this-literal">8.1.1. The this Literal</a></h4>
<div class="paragraph">
<p>This section describes the <code>this</code> literal and the semantics of the <code>@This</code> annotation, the type <code>this</code> is described in <a href="types.html#_this-type">This Type</a>.</p>
</div>
<h5 id="_semantics-9" class="discrete">Semantics</h5>
<div class="paragraph">
<p>Semantics are similar to the original ECMAScript this keyword, see [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.11.1.1, p.p.63)</a>])
Also see [<a href="appendix_c_bibliography.html#West06a">West06a</a>] and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">MozillaJSRef</a></p>
</div>
<div class="paragraph">
<p>Regarding the location where <code>this</code> may be used, the following restrictions apply:</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-173"></a><strong>Req. IDE-173:</strong> <a href="#Req-IDE-173">Valid location for this literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>The literal may not be used in</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>the initializer expression of static data fields in classes.</p>
</li>
<li>
<p>the initializer expression of data fields in interfaces (applies to both static and non-static).</p>
</li>
<li>
<p>static methods of interfaces and static field accessors of interfaces.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>See also <a href="classifiers.html#Req-IDE-69">[Req-IDE-69]</a>.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>Note: <a href="#Req-IDE-173">[Req-IDE-173]</a> also applies for this literals inside arrow expressions in initializers.</p>
</div>
<div class="paragraph">
<p>The use of <code>this</code> is illustrated with some examples as it can often be confusing.
Type inference heuristics and explanations are provided in the next section.</p>
</div>
<div class="exampleblock">
<div class="title">Example 76. This in Unrestricted Mode</div>
<div class="content">
<div class="paragraph">
<p>In unrestricted mode, <code>this</code> is bound to the receiver.
If there is no receiver it is bound to the global object, however, we often do not know exactly what the global object would be.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var name = "global a"; // assume the top level is similar to the global object
this.name; // &lt;-- "global a"
function f() {
return this.name; // &lt;-- depends on call, usually "global a"
}
var ol1 = {
name: "John",
greeting: "Hello " + this.name, // "Hello global a" -- we do not greet John!
}
var ol2 = {
name: "John",
f: function() {
this.name; // usually "John", as we assume f is called like ol2.f()
var g = function() {
return this.name; // "global a"
}
return g(); // no receiver, this in nested function g will be global scope
}
}</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 77. This in strict mode</div>
<div class="content">
<div class="paragraph">
<p>In strict mode, <code>this</code> is bound to the receiver.
If there is no receiver, it is bound to <code>undefined</code>.
Thus, we will probably get a lot of errors:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">"use strict"
var name = "global a"; // assume the top level is similar to the global object
this.name; // &lt;-- error, this is undefined, there is no receiver
function f() {
return this.name; // &lt;-- depends on call, usually this produces an error as this is undefined
}
var ol1 = {
name: "John",
greeting: "Hello " + this.name, // will produce an error, as this is undefined
}
var ol2 = {
name: "John",
f: function() {
this.name; // usually "John", as we assume f is called like ol2.f()
var g = function() {
this.name; // an error, see call below:
}
return g(); // no receiver, this in nested function g is undefined
}
}</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 78. This in N4JS mode</div>
<div class="content">
<div class="paragraph">
<p>As in strict mode, <code>this</code> is bound to the receiver and if there is no receiver, it is bound to <code>undefined</code>. So the example above is also true for N4JS mode.
Classes behave slightly differently:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A {
name = "John";
greeting = "Hello " + this.name; // works, in N4JS classes, greeting is "Hello John"
f() {
return this.name; // this usually is instance object, similar to object literals.
}
g() {
var h = function() {
return this.name; // as in object literals: no receiver, no this.
}
return h();
}
}</code></pre>
</div>
</div>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title=""></i>
</td>
<td class="content">
In N4JS classes, <code>this</code> is always bound to the instance when used in field initialization.
</td>
</tr>
</table>
</div>
<h5 id="_type-inference-2" class="discrete">Type Inference</h5>
<div class="openblock language-n4js">
<div class="content">
<div class="paragraph">
<p>The type is inferred from the <code>this</code> type is bound to. The inference,
therefore, has to consider the original semantics as described in [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.10.4., p.10.4.3, p.p.58)</a>].
In ECMAScript the type of this is unfortunately determined by the function call and not by the function definition:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>By default, <code>this</code> is bound to the global object [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.10.4.1.1)</a>].
Unfortunately it is often unknown what the global object will be at run time (e.g., node.js differs from browsers).</p>
</li>
<li>
<p>If a function is called without a receiver, <code>this</code> is bound to</p>
<div class="ulist">
<ul>
<li>
<p>the global object or</p>
</li>
<li>
<p>to <code>undefined</code> in strict mode.</p>
</li>
</ul>
</div>
</li>
<li>
<p>If a function is called with a receiver,<code>this</code> is bound to the receiver object.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Actually, <code>this</code> is bound to the newly created object if a function is called with the <code>new</code> operator.
If a function is known to be invoked with an explicit <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>t</mi><mi>h</mi><mi>i</mi><mi>s</mi><mi>A</mi><mi>r</mi><mi>g</mi></math> (<code>apply()</code> etc.), the <code>@This</code> annotation can be used to explicitly set the this type.
This annotation has precedence over otherwise inferred bindings.</p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-90"></a><strong>Req. IDE-90:</strong> <a href="#Req-IDE-90">Type Inference Heuristic for This-Keyword</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>In general, the actual this target can not be inferred from the context of the this keyword.
A heuristic is defined, however, to compute the probable this type:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a id="this-keyword-constraint-1"></a> If the this keyword is used in some function annotated with an annotation <code>@This</code>, the type specified in the annotation is used.
The inferred type is always nominal.</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>f</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>F</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>O</mi><mi>r</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mrow><mi>f</mi><mo>.</mo><mi>h</mi><mi>a</mi><mi>s</mi><mi>A</mi><mi>n</mi><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close=")" open="("><mstyle mathvariant="monospace"><mtext>"@This"</mtext></mstyle></mfenced><mspace width="3.0mm"/><mi>T</mi><mo>=</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>n</mi><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mstyle mathvariant="monospace"><mtext>["@This"]</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo></mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mo></mo><mi>T</mi></mrow></mfrac></math></p>
</div>
</li>
<li>
<p><a id="this-keyword-constraint-2"></a> If the this keyword is used in some <em>instance</em> method of a classifier or in an <em>instance</em> field initializer,<code>this</code> is bound to the <code>T</code> itself.
If the this keyword is used in some <em>static</em> method of a classifier <code>T</code> or in a <em>static</em> field initializer, the prototype type (or constructor) of the classifier is used, that is <code>type[T]</code>.
In both cases, the target is determined by using the expressions’s pseudo property <code>probableThisTarget</code>.
If the this keyword is used in a function expression assigned to an property of an object literal, the type of the object literal is used.
Note that usually this is the <code>this</code> type in instance methods, and the <code>this</code> type in static methods.</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>T</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>b</mi><mi>a</mi><mi>b</mi><mi>l</mi><mi>e</mi><mi>T</mi><mi>h</mi><mi>i</mi><mi>s</mi><mi>T</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mspace width="3.0mm"/><mi>T</mi><mo></mo><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo></mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mo></mo><mi>T</mi></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
</li>
<li>
<p>In all other cases: Non-strict mode:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>unrestricted</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo></mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>global</mtext></mstyle></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>Strict mode and N4JS mode:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo></mo><mstyle mathvariant="monospace"><mtext>unrestricted</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo></mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>global</mtext></mstyle><mstyle mathvariant="monospace"><mtext>undefined</mtext></mstyle></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>If the actual this type is defined as a structural type, the structural type information is moved to the this type itself.
This is transparent to the user in general but maybe visible in case of error messages.
That is to say that the actual this type is always a nominal type.
This is indicated by the nominal modifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mo></mo></math> (cf. <a href="#Req-IDE-90">[Req-IDE-90]</a> constraints <a href="#this-keyword-constraint-1">1</a> and <a href="#this-keyword-constraint-2">2</a>.).</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-91"></a><strong>Req. IDE-91:</strong> <a href="#Req-IDE-91">Valid Target and Argument for @This Annotation</a> (ver. 1)</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The <code>@This</code> annotation is only allowed on declared functions, function expressions (including arrow functions), methods, and field accessors, i.e. getters and setters, except static members of interfaces.</p>
</li>
<li>
<p>The type declared by way of <code>@This(..)</code> an annotation of a method or field accessor must be a subtype of the member’s containing classifier.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-92"></a><strong>Req. IDE-92:</strong> <a href="#Req-IDE-92">Single @This Annotation</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>It is not allowed to use more then one <code>@This(..)</code> annotation on an element.</p>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 79. Effect of Nominal This Type</div>
<div class="content">
<div class="paragraph">
<p>Given the following declaration</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">@This(~Object with {a: string;}) f() {}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Since the this type is always nominal, <code>~ Object</code> becomes <code>Object</code>.
In case of method call, however, the returned value becomes structural again.
In case of error messages the type of the return type is then</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">~this[Object] with {a: string;}</code></pre>
</div>
</div>
<div class="paragraph">
<p>For the sake of simplicity, additional structural members are usually
omitted in error messages, leading to</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">~this[Object]</code></pre>
</div>
</div>
<div class="paragraph">
<p>instead of</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">this[~Object]</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 80. This and Function Declaration</div>
<div class="content">
<div class="paragraph">
<p>This example demonstrates the usage of functions annotated with <code>@This</code>.
By using the argument <code>union{A,B}</code> it is possible to have two completely unrelated classes as the receiver type of the function <code>logger</code>.
To pass an actual object the <code>apply()</code> method of the function is used.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A {
log: string() { return "A was logged"; }
}
class B {
log: string() { return "B was logged"; }
}
@This(union{A,B})
function logger() { console.log("~ "+this.log()+" ~"); }
var a: A = new A();
logger.apply(a,[]); // prints "~ A was logged ~"
logger.apply( new B(),[]) // prints "~ B was logged ~"</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 81. This and Function Expressions</div>
<div class="content">
<div class="paragraph">
<p>In this example a function is created via a function expression.
The function is then assigned to member field of class B.
Via annotating the expression with <code>@This(B)</code>, access to the receiver of type B is enabled.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class B {
log(): string { return "B was logged"; } // method
logMe : {@This(B) function():void}; // reference to a function
}
var b: B = new B();
b.logMe = @This(B) function() { console.log("*&gt;"+this.log()+"&lt;*"); }
b.logMe(); // prints "*&gt;B was logged&lt;*"</code></pre>
</div>
</div>
<div class="openblock">
<div class="content">
</div>
</div>
<div class="paragraph">
<p>Note that if a function is called as a constructor function with new, the
type of <code>this</code> can be declared via annotation <code>@This(..)</code>, as shown in the following
snippet:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">@This(
~Object with {
w: number; h: number;
area: {function():number};
})
function Box(w: number w, h: number) {
this.w = w;
this.h = h;
this.area = @This(
~Object with {
w: number; h: number;
area: {function():number};
}) function() { return this.w * this.h }
}
var bError = Box(1,2)
var bOK = new Box(1,2)</code></pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>Inside the constructor function <code>Box</code>, <code>this</code> is bound to the structural type definition due to the annotation.</p>
</div>
<div class="paragraph">
<p>Inside the nested function <code>area</code>, <code>this</code> is bound to the receiver object (if the function is called like <code>bOk.area()</code>).
Again, this depends on the way the nested function is called, which can usually not be determined at the declaration location.
The nested function must then be annotated accordingly.</p>
</div>
<div class="paragraph">
<p>When calling this function, the type of this is checked against the declared this type, which would cause an error in the first case.</p>
</div>
<div class="paragraph">
<p>The use of the <code>@This</code> annotation is not allowed on methods.</p>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title=""></i>
</td>
<td class="content">
Using constructor functions is not recommended and an error or warning will be created.
This is only useful for adapting third-party library code.
Even in the latter case, it would probably make more sense to declare a (library) <strong>class</strong> Rectangle rather then defining the constructor function.
</td>
</tr>
</table>
</div>
</div>
<div class="sect3">
<h4 id="_identifier"><a class="anchor" href="#_identifier"></a><a class="link" href="#_identifier">8.1.2. Identifier</a></h4>
<h5 id="_syntax-10" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Identifiers as expressions are identifier references.
They are defined as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">IdentifierRef &lt;Yield&gt;:
id=[types::IdentifiableElement|BindingIdentifier&lt;Yield&gt;]
;
BindingIdentifier &lt;Yield&gt;:
IDENTIFIER
| &lt;!Yield&gt; 'yield'
| N4Keyword
;</code></pre>
</div>
</div>
<h5 id="_semantics-10" class="discrete">Semantics</h5>
<div class="paragraph">
<p>The type of an identifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> is resolved depending on its binding and scope respectively (cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.10.2.2.1GetIdentifierReference, p.p.56)</a>].
The following scopes (aka <em>Lexical Environments</em>) are defined:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>function local; local variables, parameters</p>
</li>
<li>
<p>zero or more function closure in case of nested functions</p>
</li>
<li>
<p>module</p>
</li>
<li>
<p>global</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These scope are nested as illustrated in <a href="#fig:scopes">Scopes</a>.</p>
</div>
<div class="paragraph">
<p>Note that classes definitions and object literal do not define a scope: members of a class or properties of an object literal are to be accessed via <code>this</code>.
Identifier references always reference declared elements, that is to say either variable, function, or class declarations.
Properties of object literals or members of a class are referenced via <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>-</mo><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi></math> (see <a href="#_property-accessors">Property Accessors</a>).</p>
</div>
<div id="fig:scopes" class="imageblock" style="text-align: center">
<div class="content">
<img src="chapters/08_expressions/fig/scopes.svg" alt="scopes">
</div>
<div class="title">Figure 7. Scopes</div>
</div>
<div class="paragraph">
<p>An identifier may be bound to a variable (global or local variable, parameter, variable defined in a function’s closure), or to a property of an object.
The latter case is known as property access as further described in <a href="#_property-accessors">Property Accessors</a>.</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-93"></a><strong>Req. IDE-93:</strong> <a href="#Req-IDE-93">Read Access to Identifier</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>If an identifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> is accessed, the bound declared element <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>D</mi></math> must be readable if it is not used on the left-hand side of an assignment expression.</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>b</mi><mi>i</mi><mi>n</mi><mi>d</mi><mfenced close=")" open="("><mi>i</mi><mi>D</mi></mfenced></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mspace width="2.0em"/><mo></mo><mo></mo><mi> </mi><mstyle mathvariant="monospace"><mtext>AssignmentExpression</mtext></mstyle><mi> </mi><mi>a</mi><mi>e</mi><mo></mo><mi>i</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><msup><mi>r</mi><mo>*</mo></msup><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mspace width="3.0em"/><mi>a</mi><mi>e</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mo>=</mo><mi>i</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mspace width="4.0em"/><mo></mo><mfenced close=")" open="("><mrow><mi>μ</mi><mfenced close=")" open="("><mrow><mi>a</mi><mi>e</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyAccessExpression</mtext></mstyle><mo></mo><mi>a</mi><mi>e</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mo>=</mo><mi>i</mi></mrow></mfenced><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mo></mo><mi>D</mi><mo>.</mo><mi>r</mi><mi>e</mi><mi>a</mi><mi>d</mi><mi>a</mi><mi>b</mi><mi>l</mi><mi>e</mi></math></p>
</div>
</div>
</div>
<h5 id="_type-inference-3" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>An identifier reference <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> is bound to an identifiable element <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mo>.</mo><mi>i</mi><mi>d</mi></math>, which is expressed with the function <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi><mi>i</mi><mi>n</mi><mi>d</mi><mfenced close=")" open="("><mi>i</mi><mrow><mi>i</mi><mo>.</mo><mi>i</mi><mi>d</mi></mrow></mfenced></math>.
The type of the reference is then inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo></mo><mi>i</mi><mi>d</mi><mi>r</mi><mi>e</mi><mi>f</mi><mo>.</mo><mi>i</mi><mi>d</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo></mo><mstyle mathvariant="monospace"><mtext>IdentifierRef</mtext></mstyle><mi> </mi><mi>i</mi><mi>d</mi><mi>r</mi><mi>e</mi><mi>f</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_literals"><a class="anchor" href="#_literals"></a><a class="link" href="#_literals">8.1.3. Literals</a></h4>
<div class="paragraph">
<p>cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.3p.63, p.S7.8p.19ff)</a>].</p>
</div>
<h5 id="_type-inference-4" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type of a literal can directly be derived from the grammar.
The following axioms are defined for literals:</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>NullLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>BooleanLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>boolean</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>NumericLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>int</mtext></mstyle><mi>o</mi><mi>r</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>StringLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>string</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>RegularExpressionLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>RegExpr</mtext></mstyle></mrow></mfrac></math></p>
</div>
<div class="paragraph">
<p>Note that there are no literals specific for <code>pathSelector</code> or <code>i18nkey</code>.</p>
</div>
<div class="sect4">
<h5 id="_integer-literals"><a class="anchor" href="#_integer-literals"></a><a class="link" href="#_integer-literals">8.1.3.1. Integer Literals</a></h5>
<div class="paragraph">
<p>Numeric literals representing integers in the range of JavaScript’s int32 are inferred to the built-in primitive type <code>int</code> instead of <code>number</code>.
The following rules apply:</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-94"></a><strong>Req. IDE-94:</strong> <a href="#Req-IDE-94">Numeric literals</a> (ver. 1)</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Numeric literals with a fraction or using scientific notation, e.g. <code>2.0</code> and <code>2e0</code>, respectively, are always inferred to <code>number</code>, even if they represent integers in the range of int32.</p>
</li>
<li>
<p>Numeric literals that represent integers in the range of JavaScript’s int32, i.e. from <math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mn>-2</mn><mn>31</mn></msup></math> to <math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mn>2</mn><mn>31</mn></msup><mo>-</mo><mn>1</mn></math>, are inferred to <code>int</code>.</p>
</li>
<li>
<p>Hexadecimal and octal literals are always interpreted as positive numbers, so all values above <code>0x7fffffff</code> and <code>017777777777</code> lie outside the range of int32 and will thus
be inferred to <code>number</code>; this is an important difference to Java. See below for further elaboration.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There are differences to numeric literals in Java:</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 12.5%;">
<col style="width: 25%;">
<col style="width: 12.5%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-center valign-top" colspan="2">Java</th>
<th class="tableblock halign-center valign-top" colspan="2">JavaScript N4JS</th>
</tr>
</thead>
<tbody>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock">Literal</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Value</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Type</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Value</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Type</p></th>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>2147483648</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>2147483647</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x7fffffff</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x80000000</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>+2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0xffffffff</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-1</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967295</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x100000000</code></p></td>
<th class="tableblock halign-center valign-top" colspan="2"><p class="tableblock">n/a</p></th>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967296</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>017777777777</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>020000000000</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>+2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>037777777777</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-1</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967295</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>040000000000</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>0</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967296</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0100000000000</code></p></td>
<th class="tableblock halign-center valign-top" colspan="2"><p class="tableblock">n/a</p></th>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>8589934592</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The literals <code>0x100000000</code> and <code>0100000000000</code> produce a syntax error in Java.</p>
</div>
<div class="paragraph">
<p>Until IDE-1881 is complete, all built-in operations always return a <code>number</code> even if all operands are of type <code>int</code>.
For the time being, we therefore interpret <code>-1</code> as a negative integer literal (inferred to <code>int</code>), but <code>-(1)</code> as the negation of a positive integer literal (inferred to <code>number</code>).</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_array-literal"><a class="anchor" href="#_array-literal"></a><a class="link" href="#_array-literal">8.1.4. Array Literal</a></h4>
<h5 id="_syntax-11" class="discrete">Syntax</h5>
<div class="paragraph">
<p>cf [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.4, p.p.63)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ArrayLiteral &lt;Yield&gt; returns ArrayLiteral:
{ArrayLiteral} '['
elements+=ArrayPadding* (
elements+=ArrayElement&lt;Yield&gt;
(',' elements+=ArrayPadding* elements+=ArrayElement&lt;Yield&gt;)*
(trailingComma?=',' elements+=ArrayPadding*)?
)?
']'
;
/**
* This array element is used to pad the remaining elements, e.g. to get the
* length and index right
*/
ArrayPadding returns ArrayElement: {ArrayPadding} ',';
ArrayElement &lt;Yield&gt; returns ArrayElement: {ArrayElement} spread?='...'? expression=AssignmentExpression&lt;In=true,Yield&gt;;</code></pre>
</div>
</div>
<h5 id="_type-inference-5" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>In general, an array literal is inferred as <code>Array&lt;T&gt;</code> (similar to the type of <code>new Array()</code>).
The interesting question is the binding of the type variable <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi></math>.</p>
</div>
<div class="paragraph">
<p>The type of an array padding <em>p</em> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo></mo><mi>p</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>undefined</mtext></mstyle></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
<div class="paragraph">
<p>The element type of an array literal is simply inferred as the (simplified) union of the type elements of the array.
Thus, the type of an array literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi></math> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo></mo><mi>a</mi><mo>.</mo><mover accent="true"><mrow><mi>e</mi><mi>l</mi><mi>e</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi></mrow><mo>¯</mo></mover><mi>:</mi><mover accent="true"><msub><mi>T</mi><mi>e</mi></msub><mo>¯</mo></mover><mi>T</mi><mo>=</mo><mo></mo><mover accent="true"><msub><mi>T</mi><mi>e</mi></msub><mo>¯</mo></mover></mrow><mrow><mi>Γ</mi><mo></mo><mfenced close=")" open="("><mi>a</mi></mfenced><mi>:</mi><mi>A</mi><mi>r</mi><mi>r</mi><mi>a</mi><mi>y</mi><mo>&lt;</mo><mi>T</mi><mo>&gt;</mo></mrow></mfrac></math>
</div>
</div>
<div class="paragraph">
<p>In other languages not supporting union types, the element type is often inferred as the join (<a href="appendix_a_acronyms.html#_acronyms">LCST</a>) of the element types.
Using a union type here preserves more information (as the actual types are still known).
For many use cases the behavior is similar though, as the members of a union type are the members of the join of the elements of the union.</p>
</div>
<div class="paragraph">
<p>Note that <code>typeof [1,2,3]</code> does not return <code>Array&lt;number&gt;</code> (as ECMAScript is not aware of the generic array type), but <code>Object</code>.</p>
</div>
<div class="exampleblock">
<div class="title">Example 82. Array Type Inference</div>
<div class="content">
<div class="paragraph">
<p>The type for all variables declared in this example is inferred to <code>Array&lt;string&gt;</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var names1 = ["Walter", "Werner"];
var names2 = new Array("Wim", "Wendelin");
var names3 = new Array&lt;string&gt;(3); // length is 3
var names4: Array&lt;string&gt;;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Empty array literals are inferred to <code>any</code>, by default.
We are not using <code>Array&lt;?&gt;</code> here because then a typical JavaScript pattern would no longer be supported:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var a = [];
a.push('hello'); <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>This would fail if <code>a</code> and thus <code>[]</code> were inferred to <code>Array&lt;?&gt;</code></td>
</tr>
</table>
</div>
</div>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title=""></i>
</td>
<td class="content">
An important exception; if a type expectation exists for the empty array literal and the expected type is <code>Array&lt;T&gt;</code>, this will be used as the type of the array literal.
</td>
</tr>
</table>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-95"></a><strong>Req. IDE-95:</strong> <a href="#Req-IDE-95">Empty array literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>An empty array literal will be inferred as follows:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>If there is a type expectation for the empty array literal and the expected type is <code>Array&lt;T&gt;</code>, for any type <code>T</code>, then the type of the empty array literal will be inferred to <code>Array&lt;T&gt;</code>.</p>
</li>
<li>
<p>Otherwise, the type of the empty array literal will be inferred to <code>Array&lt;any&gt;</code>.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_object-literal"><a class="anchor" href="#_object-literal"></a><a class="link" href="#_object-literal">8.1.5. Object Literal</a></h4>
<div class="paragraph">
<p>In addition to ordinary Javascript object literals, N4JS supports the spread operator within object literals as introduced in [<a href="appendix_c_bibliography.html#ECMA18a">ECMA18a</a>].</p>
</div>
<h5 id="object-literal-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.5, p.p.65ff)</a>]
The syntax of an object literal is given by:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ObjectLiteral &lt;Yield&gt;: {ObjectLiteral}
'{'
( propertyAssignments+=PropertyAssignment&lt;Yield&gt;
(',' propertyAssignments+=PropertyAssignment&lt;Yield&gt;)* ','?
)?
'}'
;
PropertyAssignment &lt;Yield&gt;:
PropertyNameValuePair&lt;Yield&gt;
| PropertyGetterDeclaration&lt;Yield&gt;
| PropertySetterDeclaration&lt;Yield&gt;
| PropertyMethodDeclaration&lt;Yield&gt;
| PropertyNameValuePairSingleName&lt;Yield&gt;
| PropertySpread&lt;Yield&gt;
;
PropertyMethodDeclaration &lt;Yield&gt;:
=&gt; ({PropertyMethodDeclaration}
annotations+=Annotation*
TypeVariables? returnTypeRef=TypeRef?
(
generator?='*' LiteralOrComputedPropertyName&lt;Yield&gt; -&gt;MethodParamsAndBody&lt;Generator=true&gt;
| LiteralOrComputedPropertyName&lt;Yield&gt; -&gt;MethodParamsAndBody &lt;Generator=false&gt;
)
)
';'?
;
PropertyNameValuePair &lt;Yield&gt;:
=&gt; (
{PropertyNameValuePair}
annotations+=Annotation*
declaredTypeRef=TypeRef? LiteralOrComputedPropertyName&lt;Yield&gt; ':'
)
expression=AssignmentExpression&lt;In=true,Yield&gt;
;
/*
* Support for single name syntax in ObjectLiteral (but disallowed in actual object literals by ASTStructureValidator
* except in assignment destructuring patterns)
*/
PropertyNameValuePairSingleName &lt;Yield&gt;:
declaredTypeRef=TypeRef?
identifierRef=IdentifierRef&lt;Yield&gt;
('=' expression=AssignmentExpression&lt;In=true,Yield&gt;)?
;
PropertyGetterDeclaration &lt;Yield&gt;:
=&gt;(
{PropertyGetterDeclaration}
annotations+=Annotation*
GetterHeader&lt;Yield&gt;
)
body=Block&lt;Yield=false&gt;
;
PropertySetterDeclaration &lt;Yield&gt;:
=&gt;(
{PropertySetterDeclaration}
annotations+=Annotation*
'set'
-&gt;LiteralOrComputedPropertyName &lt;Yield&gt;
)
'(' fpar=FormalParameter&lt;Yield&gt; ')' body=Block&lt;Yield=false&gt;
;
PropertySpread &lt;Yield&gt;:
'...' expression=AssignmentExpression&lt;In=true,Yield&gt;
;</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">import Address from "my/Address";
var simple = {name: "Walter", age: 72, address: new Address()};</code></pre>
</div>
</div>
<div class="sect4">
<h5 id="_properties-6"><a class="anchor" href="#_properties-6"></a><a class="link" href="#_properties-6">8.1.5.1. Properties</a></h5>
<div class="paragraph">
<p>PropertyAssignments have common properties of PropertyNameValuePair, PropertyGetterDeclaration, and PropertySetterDeclaration:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>annotations</code> </dt>
<dd>
<p>The annotations of the property assignment.</p>
</dd>
<dt class="hdlist1"><code>name</code> </dt>
<dd>
<p>The name of the property. This may be an identifier, a string or a numeric literal.
When comparing names, we implicitly assume the name to be converted to an identifier, even if this identifier is not a valid ECMAScript identifier.</p>
</dd>
<dt class="hdlist1"><code>declaredType</code> </dt>
<dd>
<p>The declared type of the property which may be null.
This property is a pseudo property for PropertySetterDeclaration, in this case it is derived from the declared type of the setter’s formal parameter.</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>Additionally, we introduce the following pseudo properties to simplify constraints:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>isAccessor</code> </dt>
<dd>
<p>The read-only boolean property. This is true if the property assignment is a setter or getter declaration.
This is comparable to ECMAScript’s spec function <code>IsAccessoprDescriptor</code>.
For a given property assignment <em>p</em> this is semantically equivalent to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyGetterDeclaration</mtext></mstyle><mo></mo><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertySetterDeclaration</mtext></mstyle></math>.</p>
</dd>
<dt class="hdlist1"><code>isData</code> </dt>
<dd>
<p>The read-only boolean property.
This is true if the property assignment is a name value pair.
For a given property assignment <em>p</em> this is semantically equivalent to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyNameValuePair</mtext></mstyle></math>.
It is comparable to ECMAScript’s spec function <code>isDataDescriptor</code>.
The equation <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mi>s</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi><mo>=</mo><mo>¬</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>a</mi><mi>t</mi><mi>a</mi></math> is always true.</p>
</dd>
</dl>
</div>
<h5 id="properties-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-96"></a><strong>Req. IDE-96:</strong> <a href="#Req-IDE-96">Object literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given object literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>o</mi><mi>l</mi></math> the following constraints must hold (cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the name of each property is given as an identifier, a string literal, a numeric literal, or as a computed property name with a compile-time expression (see <a href="#compile-time-expressions">Compile-Time Expressions</a>). In particular, string literals, e.g. <code>['myProp']</code>, built-in symbols, e.g. <code>[Symbol.iterator]</code>, and literals of <code>@StringBased</code> enums are all valid computed property names.</p>
</li>
<li>
<p>Object literal may not have two PropertyNameValuePairs with the same name in strict mode (cf. 4.a [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]):</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>strict</mtext></mstyle><mo></mo><mspace width="3.0mm"/><mo></mo><mi>p</mi><mi>a</mi><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mo>,</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>a</mi><mi>t</mi><mi>a</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mo></mo><mi>p</mi><msup><mi>a</mi><mi>'</mi></msup><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>p</mi><msup><mi>a</mi><mi>'</mi></msup><mo>.</mo><mi>i</mi><mi>s</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi><mo></mo><mi>p</mi><msup><mi>a</mi><mi>'</mi></msup><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math></p>
</div>
</li>
<li>
<p>Object literal may not have PropertyNameValuePair and <code>PropertyGetterDeclaration</code>/<code>PropertySetterDeclaration</code> with the same name (cf. 4.b/c [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]):</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mo></mo><mspace width="3.0mm"/><mi>p</mi><mi>a</mi><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mo>,</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>a</mi><mi>t</mi><mi>a</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo></mo><mspace width="3.0mm"/><mi>p</mi><mi>g</mi><mi>s</mi><mi>d</mi><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>g</mi><mi>s</mi><mi>d</mi></mrow></mfenced><mo></mo><mstyle mathvariant="monospace"><mtext>PropertyNameValuePair</mtext></mstyle><mo></mo><mi>p</mi><mi>g</mi><mi>s</mi><mi>d</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math></p>
</div>
</li>
<li>
<p>Object literal may not have multiple <code>PropertyGetterDeclaration</code> or <code>PropertySetterDeclaration</code> with the same name (cf. 4.d [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]):</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mo></mo><mspace width="3.0mm"/><mi>p</mi><mi>g</mi><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mo>,</mo><mi>p</mi><mi>g</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo></mo><mspace width="3.0mm"/><mi>p</mi><msup><mi>g</mi><mi>'</mi></msup><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mfenced close="}" open="{"><mrow><mi>p</mi><mi>g</mi></mrow></mfenced><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><msup><mi>g</mi><mi>'</mi></msup></mrow></mfenced><mo>=</mo><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>g</mi></mrow></mfenced><mo></mo><mi>p</mi><msup><mi>g</mi><mi>'</mi></msup><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>g</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math></p>
</div>
</li>
</ul>
</div>
<div class="quoteblock">
<blockquote>
It is a SyntaxError if the Identifier <code>eval</code> or the Identifier <code>arguments</code> occurs as the Identifier in a <code>PropertySetParameterList</code> of a <code>PropertyAssignment</code> that is contained in strict code or if its
<code>FunctionBody</code> is strict code. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]
</blockquote>
</div>
<div class="ulist">
<ul>
<li>
<p>If two or more property assignments have the same name (and the previous conditions hold), then the types of these assignments must <em>conform</em>.
That is to say that the inferred (but not declared) type of all assignments must be type of probably declared types and if the types are explicitly declared, they must be equal.</p>
</li>
<li>
<p>In N4JS mode, the name of a property must be a valid N4JSIdentifier:</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>n4js</mtext></mstyle><mo></mo><mspace width="3.0mm"/><mo></mo><mi>p</mi><mi>a</mi><mo></mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>a</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>N4JSIdentifier</mtext></mstyle></math></p>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-22501"></a><strong>Req. IDE-22501:</strong> <a href="#Req-IDE-22501">Superfluous properties of an object literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>Let <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math> be the expected type of an object literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> as defined by the context in which <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> is used.
If <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math> is not type <code>Object</code> and not dynamic, then the compiler creates a warning <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> contains properties not found in <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math>.</p>
</div>
<div class="paragraph">
<p>This is true in particular for object literals passed in as arguments of a spec-constructor.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="_scoping-and-linking"><a class="anchor" href="#_scoping-and-linking"></a><a class="link" href="#_scoping-and-linking">8.1.5.2. Scoping and linking</a></h5>
<div class="exampleblock">
<div class="title">Example 83. Scoping and linking</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var p = {
f: function() {
console.log("p´s f");
},
b: function() {
this.f();
},
o: {
nested: "Hello"
}
};
p.b();
p.o.nested;</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Other properties within an object literal property can be accessed using this.
In the expression of property name value pairs, however, <code>this</code> is not be bound to the containing object literal, but usually to undefined or global.</p>
</li>
<li>
<p>The properties of an object literal are accessible from outside.</p>
</li>
<li>
<p>Nested properties of an object literal are also accessible from outside.</p>
</li>
</ul>
</div>
</div>
</div>
<h5 id="type-inference-3" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>An object literal implicitly extends <code>~Object</code>, therefore, object literal types use structural typing.
For details see <a href="classifiers.html#_structural-typing">Structural Typing</a>.
From a type systems point of view, the two variables <code>ol</code> and <code>st</code> below have the same type.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var ol = {
s: "hello",
n: 42
}
var st: ~Object with { s: string; n: number;};</code></pre>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_parenthesized-expression-and-grouping-operator"><a class="anchor" href="#_parenthesized-expression-and-grouping-operator"></a><a class="link" href="#_parenthesized-expression-and-grouping-operator">8.1.6. Parenthesized Expression and Grouping Operator</a></h4>
<div class="paragraph">
<p>The grouping operator is defined here as a parenthesized expression.</p>
</div>
<h5 id="parenthesized-expression-grouping-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.6, p.p.67)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ParenExpression &lt;Yield&gt;: '(' expression=Expression&lt;In=true,Yield&gt; ')';</code></pre>
</div>
</div>
<h5 id="Grouping-Operator-type-inference" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type of the grouping operator simply is the type of its nested expression.
The type if a parenthesized expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>e</mi></math> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo></mo><mi>e</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo></mo><mstyle mathvariant="monospace"><mtext>’(’</mtext></mstyle><mi>e</mi><mstyle mathvariant="monospace"><mtext>’)’</mtext></mstyle><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 84. Parenthesized Expression Type Examples</div>
<div class="content">
<div class="paragraph">
<p>In the following listing, the type of the plain expressions is equivalent to the parenthesized versions:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A{} class B extends A{}
var f: boolean; var a: A a; var b: B;
/* simple &lt;-&gt; parenthesized */
10; (10);
"hello"; ("hello");
true; (true);
a; (a);
10-5; (10-5);
f?a:b (f?a:b);</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_property-accessors"><a class="anchor" href="#_property-accessors"></a><a class="link" href="#_property-accessors">8.1.7. Property Accessors</a></h4>
<h5 id="property-accessor-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Property accessors in N4JS are based on [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.1, p.p.67ff)</a>].
They cannot only be used for accessing properties of an object, but also for accessing members of a class instance.
In order to support parameterized calls, the syntax is extended to optionally allow type arguments.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ParameterizedPropertyAccessExpression:
target=PrimaryExpression&lt;Yield&gt; ParameterizedPropertyAccessExpressionTail&lt;Yield&gt;
;
IndexedAccessExpression:
target=PrimaryExpression&lt;Yield&gt; IndexedAccessExpressionTail&lt;Yield&gt;
;
fragment IndexedAccessExpressionTail &lt;Yield&gt;*:
'[' index=Expression&lt;In=true,Yield&gt; ']'
;
fragment ParameterizedPropertyAccessExpressionTail &lt;Yield&gt;*:
'.' TypeArguments? property=[types::IdentifiableElement|IdentifierName]
;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that in [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a</a>], the <code>index access</code> is called <code><em>bracket notation</em></code>.</p>
</div>
<h5 id="property-access-direct" class="discrete">Direct Property Access</h5>
<div class="paragraph">
<p>We define a special case of property access as follows:</p>
</div>
<div class="openblock definition">
<div class="content">
<div class="paragraph">
<p><a id="direct_property_access"></a><strong>Definition:</strong> <a href="#direct_property_access">Direct Property Access</a></p>
</div>
<div class="paragraph">
<p>A property access expression is called <em>direct</em>, iff</p>
</div>
<div class="ulist">
<ul>
<li>
<p>its target is an identifier reference to a class, interface, enum, or the built-in object <code>Symbol</code>, and</p>
</li>
<li>
<p>its property name denotes an <em>owned</em> member of the target classifier (not an inherited, consumed, or polyfilled member) or a literal if the target is an enum.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="paragraph">
<p>As a consequence, a direct property access can only refer to static members.</p>
</div>
<div class="paragraph">
<p>The first requirement of the above definition rules out property access expressions that do not directly point to their target classifier or enum, as shown in the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class C {
const field = 'hello';
}
C.field; // direct property access to 'field'
let ctor = C;
ctor.field; // *not* a direct property access to 'field'</code></pre>
</div>
</div>
<div class="paragraph">
<p>Direct property access is the only form of property access allowed in compile-time expressions, cf. <a href="#compile-time-expressions">Compile-Time Expressions</a>.</p>
</div>
<div class="sect4">
<h5 id="properties-1"><a class="anchor" href="#properties-1"></a><a class="link" href="#properties-1">8.1.7.1. Properties</a></h5>
<div class="paragraph">
<p>We define the following properties:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>target</code> </dt>
<dd>
<p>The receiver of the property access.</p>
</dd>
<dt class="hdlist1"><code>index</code> </dt>
<dd>
<p>The index expression in case of an IndexedAccessExpression (returns <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></math> otherwise).</p>
</dd>
<dt class="hdlist1"><code>property</code> </dt>
<dd>
<p>The name of the property in case of non-indexed-access expressions (returns <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></math> otherwise, although the index may be interpreted as property name).</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>We define the following pseudo properties:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>isDotAccess</code> </dt>
<dd>
<p>Read-only boolean property, returns true for non-index access expression (similar to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo></mo><mstyle mathvariant="monospace"><mtext>IndexedAccessExpression</mtext></mstyle></math>).</p>
</dd>
<dt class="hdlist1"><code>isIndexAccess</code> </dt>
<dd>
<p>Read-only boolean property, returns true for index access expression (similar to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>IndexedAccessExpression</mtext></mstyle></math>.<br>
The equation <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>=</mo><mo>¬</mo><mi>p</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>I</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>x</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi></math> is always true.</p>
</dd>
<dt class="hdlist1"><code>name</code> </dt>
<dd>
<p>Returns the name of the property.
This is either the <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi></math> converted to a simple name or the index converted to a name (where possible) if it is an indexed-accessed expression.</p>
</dd>
</dl>
</div>
<h5 id="property-acessors-semantics" class="discrete">Semantics</h5>
<div class="paragraph">
<p>The parameterization is part of the property access in case of generic methods.
For generic functions, a parameterized function call is introduced (cf. <a href="#_function-calls">Function Calls</a>).
The constraints are basically similar.</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-97"></a><strong>Req. IDE-97:</strong> <a href="#Req-IDE-97">Property Access and Dot Notation</a> (ver. 1)</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>If dot notation is used in N4JS mode, the referenced property must exist unless receiver is a dynamic type:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo></mo><mo>¬</mo><mi>R</mi><mo>.</mo><mi>d</mi><mi>y</mi><mi>n</mi><mo></mo><mtext>
</mtext><mspace width="3.0mm"/><mo></mo><mi>m</mi><mo></mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>i</mi><mi>e</mi><mi>s</mi><mi>:</mi><mi>m</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math>
</div>
</div>
</li>
<li>
<p>If dot notation is used and the referenced property exists, then the property must be accessible:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo></mo><mo>¬</mo><mi>R</mi><mo>.</mo><mi>d</mi><mi>y</mi><mi>n</mi><mo></mo><mtext>
</mtext><mspace width="3.0mm"/><mfenced close=")" open="("><mrow><mo></mo><mi>m</mi><mo></mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>i</mi><mi>e</mi><mi>s</mi><mi>:</mi><mi>m</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></mrow></mfenced><mo></mo><mi>α</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>a</mi><mi>e</mi></mrow><mi>m</mi></mfenced></math>
</div>
</div>
</li>
<li>
<p>If dot notation is used and the referenced property exists and this property is a member with a declared <code>@This</code> type (only possible for methods or field accessors),
then the receiver must be a subtype of the declared <code>@This</code> type.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-98"></a><strong>Req. IDE-98:</strong> <a href="#Req-IDE-98">Index Access</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>An index access expression is valid iff one of the following cases applies:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>the receiver is of a dynamic type. In this case, the index may be any expression (need not be a compile-time expression).</p>
</li>
<li>
<p>the receiver is an immediate instance of <code>Object</code>, i.e. it is a subtype of <code>Object</code> and its super types but <strong>not</strong> of any other type including <code>~Object</code> and <code>~~Object</code>.</p>
</li>
<li>
<p>the receiver is of type Array, ArgumentType, string, or String (including their subtypes) <strong>and</strong> the index is an expression of type <code>number</code>.</p>
</li>
<li>
<p>the index expression is a compile-time expression</p>
<div class="ulist">
<ul>
<li>
<p><strong>and</strong> the receiver type defines a member with a name equal to the string representation of the index expression&#8217;s compile-time value<br></p>
</li>
<li>
<p><strong>and</strong> the receiver is not an enum.</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="paragraph">
<p>Although index access is very limited, it is still possible to use immediate instances of <code>Object</code> in terms of a map (but this applies only to index access, not the dot notation):</p>
</div>
<div class="exampleblock">
<div class="title">Example 85. Object as Map</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var map: Object = new Object();
map["Kant"] = "Imperative";
map["Hegel"] = "Dialectic";
map.spinoza = "Am I?"; // error: Couldn't resolve reference to IdentifiableElement 'spinoza'.</code></pre>
</div>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-99"></a><strong>Req. IDE-99:</strong> <a href="#Req-IDE-99">Parameterized Property Access</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a parameterized property access expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>a</mi><mi>e</mi></math>, the following constraints must hold:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The receiver or target must be a function or method:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mstyle mathvariant="monospace"><mtext>Function</mtext></mstyle></math></p>
</li>
<li>
<p>The number of type arguments must match the number of type parameters of the generic function or method:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>|</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>A</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo><mo>=</mo><mo>|</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>V</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo></math></p>
</li>
<li>
<p>The type arguments of a parameterized property access expression must be subtypes of the boundaries of the parameters of the called generic method.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Also see constraints on read (<a href="#Req-IDE-93">[Req-IDE-93]</a>) and write (<a href="#Req-IDE-121">[Req-IDE-121]</a>) access.</p>
</div>
</div>
</div>
<h5 id="type-inference-5" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.1, p.p.67ff)</a>]</p>
</div>
<div class="paragraph">
<p>We define the following type inferencing rules for property accessors:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The type of an indexed-access expression <em>p</em> is inferred as follows:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mo>¬</mo><mi>p</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>d</mi><mi>y</mi><mi>n</mi><mo></mo><mi>p</mi><mo>.</mo><mi>i</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>x</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mfenced close="]" open="["><mrow><mi>n</mi><mi>u</mi><mi>m</mi><mi>b</mi><mi>e</mi><mi>r</mi></mrow></mfenced><mspace width="3.0mm"/><mi>Γ</mi><mo></mo><mi>p</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>Array</mtext></mstyle><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>T</mtext></mstyle><mo>&gt;</mo></mrow><mrow><mi>Γ</mi><mo></mo><mi>p</mi><mi>:</mi><mi>T</mi></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow><mi>e</mi><mi>l</mi><mi>s</mi><mi>e</mi></mrow><mrow><mi>Γ</mi><mo></mo><mi>p</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</li>
<li>
<p>The type of a property access expression is inferred as follows:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mi>Γ</mi><mo></mo><mi>θ</mi><mfenced close=")" open="("><mi>R</mi></mfenced><mo></mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mi>:</mi><mi>R</mi><mspace width="3.0mm"/><mi>Γ</mi><mo></mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>:</mi><mi>T</mi></mrow><mrow><mstyle mathvariant="monospace"><mtext>PropertyAccessExpression</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>:</mi><mi>T</mi></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</li>
<li>
<p>The type of a parameterized access expression <em>p</em> is inferred as follows:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mo></mo><mi>m</mi><mo></mo><mi>p</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mi>:</mi><mi>m</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mspace width="3.0mm"/><mi>Γ</mi><mo></mo><mi>m</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo></mo><mi>p</mi><mi>:</mi><mi>T</mi></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow/><mrow><mi>Γ</mi><mo></mo><mi>p</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_new-expression"><a class="anchor" href="#_new-expression"></a><a class="link" href="#_new-expression">8.1.8. New Expression</a></h4>
<div class="paragraph">
<p>cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.2, p.p.68)</a>]</p>
</div>
<h5 id="new-expression-syntax" class="discrete">Syntax</h5>
<div class="listingblock">
<div class="content">