Language & Runtime
Language Contract
Last updated 2026-04-13
Language Contract
This document describes the currently implemented language surface. Planned extensions are called out explicitly instead of being implied.
Baseline Rules
- Guest code always runs with strict semantics.
- Input is script-only; module syntax is rejected.
- Unsupported features fail closed with explicit diagnostics.
- Free references to forbidden ambient globals are rejected when lexical resolution proves they are unresolved.
- Free
evaland freeFunctionare rejected for the same reason.
Supported Value Types
undefinednull- booleans
- numbers
- strings
- arrays
- plain objects
MapSet- conservative
Dateobjects - conservative
Intl.DateTimeFormatandIntl.NumberFormatformatter objects - guest functions
Supported End-to-End Syntax
- variable declarations with
letandconst - function declarations and expressions, including rest parameters and default parameter initializers
asyncfunction declarations and expressions- arrow functions
awaitinside async functions- literals, arrays, and plain-object literals with static keys, computed keys, method shorthand, and spread from plain objects or arrays
if,switch,while,do...while,for,for...of,for await...of,for...in,break, andcontinuereturnthrow,try,catch, andfinally- common destructuring, including conservative default initializers
- assignment to identifiers, member expressions, and conservative array/object destructuring targets
- sequence expressions
- member access, calls, and
newfor supported built-ins - template literals
- optional chaining
- nullish coalescing
- update expressions
- binary
**,in, and conservativeinstanceof - named host capability calls
Supported Function Call Surface
- non-arrow guest member calls bind the computed receiver as
this - arrow functions capture lexical
thisfrom the surrounding supported guest frame, including top-level script execution and ordinary guest member calls - rest parameters are supported for function declarations, function expressions, and arrow functions
newremains limited to the documented conservative built-in constructors
Supported Async Surface
- async functions return guest promise values
awaitsuspends the current async continuation onto the runtime microtask queuefor await...ofis supported inside async functions over the documented iterable surface by awaiting each yielded value before the loop body runs- host capability calls inside async guest code return guest promises and still
suspend through the existing
start()/resume()boundary new Promise(executor)is available whenexecutoris callable and completes synchronously from the runtime's perspectivePromise.resolve(...),Promise.reject(...),Promise.all(...),Promise.race(...),Promise.any(...), andPromise.allSettled(...)are available- promise instance methods
then(...),catch(...), andfinally(...)are available - promise resolution and
awaitadopt guest promises plus guest object or array thenables with callable.thenproperties - Promise executor and thenable resolve/reject functions keep first-settlement semantics; later resolve/reject calls and post-settlement throws do not override the settled result
Promise.any(...)rejects with a guest-visibleAggregateErrorobject whoseerrorsproperty preserves rejection reasons in iteration order- async Promise executors and async adopted
.thenhandlers reject with an explicitTypeError - synchronous host suspensions from Promise executors and adopted thenables still fail closed
Supported BigInt Surface
- guest code supports
BigIntliterals such as123n - exact-integer
+,-,*,/, and%are supported when both operands areBigInt - exact-integer
**is supported when both operands areBigIntand the exponent is a non-negativeBigInt typeof valuereports"bigint"for guestBigIntvaluesBigInttruthiness, string coercion, and property-key coercion are supportedMapandSetmembership support guestBigIntkeys- mixed
BigInt/Numberarithmetic and relational comparisons fail closed - unary
+1n,Number(1n), andJSON.stringify(...)ofBigIntvalues fail closed with explicit runtime errors - guest
BigIntvalues remain guest-internal and cannot cross the structured host boundary
Supported Iteration Surface
for...ofsupports either exactly onelet/constbinding declaration or an identifier/member assignment target in the loop headerfor...insupports the same header forms as the documentedfor...ofsurface, but only when the right-hand side is a plain object or array- arrays, strings,
Map,Set, and guest iterator objects from the supported helper surface are iterable in the current surface - declaration headers can use the same identifier, array, and object destructuring forms already supported elsewhere in the runtime
- assignment-target headers support identifiers, members, and the same conservative array/object destructuring forms supported by ordinary assignment
- each
for...ofiteration gets a fresh lexical binding environment for declaration headers; assignment-target headers reuse the existing binding or member reference each iteration - array iteration yields values in ascending numeric index order, treats holes
as
undefined, and ignores non-index properties - active array iterators observe the live backing array length, so elements appended before exhaustion are visited in order
- strings iterate by Unicode scalar values and preserve source order
Mapdefault iteration yields[key, value]entry pairs in insertion orderSetdefault iteration yields values in insertion order- public iterator helper methods
values(),keys(), andentries()are available on arrays and keyed collections, and produced iterator objects expose a guest-visible.next()method - unsupported iterable inputs such as plain objects, promises, and custom
symbol-based iterables throw a runtime
TypeError - abrupt completion from
break,continue,return, orthrowdiscards the internal iterator state with no user-visible iterator-close hook because generators and custom iterator authoring remain deferred
Supported Keyed Collection Surface
new Map(iterable)andnew Set(iterable)accept the supported iterable surfaceMapsupportsget,set,has,delete,clear, andsizeSetsupportsadd,has,delete,clear, andsizeMapkeys andSetmembership use SameValueZero semantics:NaNmatchesNaN,-0and0address the same entry, strings compare by string contents, and heap values compare by guest identityMapandSetpreserve first-in insertion order internally; updating an existing entry does not move it,deleteremoves the entry, andclearempties the collectionMap.prototype.entries,Map.prototype.keys,Map.prototype.values,Set.prototype.entries,Set.prototype.keys, andSet.prototype.valuesreturn guest iterator objects that preserve insertion orderMap(iterable)expects each produced item to be a guest array pair and uses the first two elements as[key, value]- custom string properties on
MapandSetinstances are currently unsupported and fail closed
Rejected With Validation Diagnostics
import,export, and dynamicimport()deletefor plain objects and arrays- free
arguments - free
evaland freeFunction - free references to
process,module,exports,global,require,setTimeout,setInterval,queueMicrotask, andfetch with- classes
- generators and
yield var,using, andawait usingfor...ofdeclaration headers that do not declare exactly oneletorconstbinding, and declaration initializers infor...of/for...inheadersdebugger- labeled statements
- object literal accessors
Explicit Deferrals
- fully general Promise constructor and thenable-adoption edge cases, including hostile thenable cycles
- unsupported assignment operators such as the bitwise and shift assignment families
- full
thissemantics beyond the current basic function-call behavior - implicit
argumentsobject semantics - legacy
varhoisting, same-scope redeclaration, and loop interaction rules - plain-object and array deletion semantics, including sparse-array behavior
- symbol-based custom iterable protocol support
- custom iterator authoring beyond the documented collection helpers
- module loading
- property descriptor semantics
- full prototype semantics
- accessors
- symbols
- typed arrays
- full
Dateparity beyond the documented conservative subset - full
Intlparity beyond the documented conservative subset Proxy
Deliberate V1 Decisions
varis intentionally out of scope for v1. The supported binding surface is lexicallet/constonly, so the runtime does not emulate function or global hoisting, same-scope redeclaration, or legacy loop-scoping behavior.- The
deleteoperator is intentionally out of scope for plain objects and arrays. Supporting it would require an explicit model for own-property absence, sparse arrays, JSON/host-boundary interactions, and whether descriptor-level configurability exists at all. Until that broader model is chosen, validation rejects every use of the language operator. This does not affect the supportedMap.prototype.deleteandSet.prototype.deletecollection methods. instanceofis intentionally conservative in v1. The supported surface is constructor-instance checks for the runtime's built-in instance kinds, conservative primitive-wrapper objects, andObjectchecks over the runtime's callable values. Guest-function constructors are accepted on the right-hand side but currently returnfalsebecausenewon guest functions and full prototype-link semantics remain deferred.
Diagnostics and Tracebacks
- Parse and validation failures preserve guest source spans.
- Runtime and limit failures render guest-safe tracebacks using guest function names and guest source spans.
- Guest
throw/catchpreserves the thrown guest value. Built-in error constructors create guest objects withnameandmessage, and sanitized host failures may also exposecodeanddetails. - Guest-visible stack information is limited to guest function names and guest source spans.
- Current traceback precision is function-level span data rather than exact-expression locations.
- Guest-facing rendering does not include host paths, internal filenames, or Rust implementation details.
Observable Ordering
- The currently supported observable property-order surface is
JSON.stringify,for...ofover the documented iterable surface,Map/Setiteration helpers, and the supportedObject.keys/Object.values/Object.entrieshelpers. JSON.stringifyon plain objects follows JavaScript own-property order: array-index keys in ascending numeric order, then remaining string keys in insertion order.JSON.stringifyon arrays renders elements in ascending numeric index order.- Sparse array holes are supported in literals and array storage. Reading a
hole yields
undefined,Object.keys/Object.values/Object.entries/for...inskip missing indices, array iteration treats holes asundefined, andJSON.stringifyrenders holes asnull. - Non-index array properties are ignored by
JSON.stringify. JSON.stringifyomits object properties whose values areundefinedor callable, serializes those values asnullinside arrays, returnsundefinedfor top-levelundefinedor callable inputs, serializes non-finite numbers asnull, and renders supportedDatevalues as UTC RFC3339 timestamps.- Array
for...ofyields values in ascending numeric index order. - String iteration yields characters in source order.
Mapiteration andMap.prototype.entries/keys/valuespreserve insertion order.Setiteration andSet.prototype.entries/keys/valuespreserve insertion order.Object.keys,Object.values, andObject.entrieson plain objects follow the same JavaScript own-property order asJSON.stringify.Object.keys,Object.values, andObject.entrieson arrays enumerate present numeric indices in ascending order followed by custom string properties in insertion order.- Canonical array-index keys are the standard JavaScript string forms such as
"0"and"10"; non-canonical numeric-looking keys such as"01"and"4294967295"remain ordinary string properties. for...inover plain objects and arrays uses the same documented key order asObject.keys(...); other right-hand sides fail closed with the same runtimeTypeErrorsurface as the supportedObjecthelpers.
Built-Ins and Global Names
globalThisObjectArrayMapSetPromiseRegExpDateStringErrorTypeErrorReferenceErrorRangeErrorNumberBooleanIntlMathJSONconsolewith deterministiclog,warn, anderrormethods when the host explicitly provides those callbacks
Currently Implemented Built-In Members
Array.isArrayArray.fromArray.ofArray.prototype.pushArray.prototype.popArray.prototype.sliceArray.prototype.spliceArray.prototype.concatArray.prototype.atArray.prototype.joinArray.prototype.includesArray.prototype.indexOfArray.prototype.lastIndexOfArray.prototype.reverseArray.prototype.fillArray.prototype.sortArray.prototype.valuesArray.prototype.keysArray.prototype.entriesArray.prototype.forEachArray.prototype.mapArray.prototype.filterArray.prototype.findArray.prototype.findIndexArray.prototype.findLastArray.prototype.findLastIndexArray.prototype.someArray.prototype.everyArray.prototype.flatArray.prototype.flatMapArray.prototype.reduceArray.prototype.reduceRightObject.keysObject.valuesObject.entriesObject.assignObject.fromEntriesObject.hasOwnMap.prototype.getMap.prototype.setMap.prototype.hasMap.prototype.deleteMap.prototype.clearMap.prototype.sizeMap.prototype.entriesMap.prototype.keysMap.prototype.valuesMap.prototype.forEachSet.prototype.addSet.prototype.hasSet.prototype.deleteSet.prototype.clearSet.prototype.sizeSet.prototype.entriesSet.prototype.keysSet.prototype.valuesSet.prototype.forEachPromise.resolvePromise.rejectPromise.allPromise.racePromise.anyPromise.allSettledPromise.prototype.thenPromise.prototype.catchPromise.prototype.finallyRegExp.prototype.execRegExp.prototype.testDate.nowDate.prototype.getTimeDate.prototype.toISOStringDate.prototype.toJSONDate.prototype.getUTCFullYearDate.prototype.getUTCMonthDate.prototype.getUTCDateDate.prototype.getUTCHoursDate.prototype.getUTCMinutesDate.prototype.getUTCSecondsNumber.parseIntNumber.parseFloatNumber.isNaNNumber.isFiniteNumber.isIntegerNumber.isSafeInteger- global
parseInt - global
parseFloat - global
isNaN - global
isFinite - global
NaN - global
Infinity String.prototype.trimString.prototype.trimStartString.prototype.trimEndString.prototype.includesString.prototype.startsWithString.prototype.endsWithString.prototype.indexOfString.prototype.lastIndexOfString.prototype.charAtString.prototype.atString.prototype.sliceString.prototype.substringString.prototype.toLowerCaseString.prototype.toUpperCaseString.prototype.repeatString.prototype.concatString.prototype.padStartString.prototype.padEndString.prototype.splitString.prototype.replaceString.prototype.replaceAllString.prototype.searchString.prototype.matchString.prototype.matchAllIntl.DateTimeFormatIntl.NumberFormatMath.absMath.maxMath.minMath.floorMath.ceilMath.roundMath.powMath.sqrtMath.truncMath.signMath.logMath.expMath.log2Math.log10Math.sinMath.cosMath.atan2Math.hypotMath.cbrtMath.randomJSON.stringifyJSON.parseconsole.logwhen the host provides aconsole.logcallbackconsole.warnwhen the host provides aconsole.warncallbackconsole.errorwhen the host provides aconsole.errorcallback
Current Helper Constraints
- array literals plus call and constructor argument lists support spread over
the documented iterable surface (
Array,String,Map,Set, and supported iterator objects); array holes iterate asundefined, and other inputs fail closed withTypeError: value is not iterable in the supported surface - array callback helpers snapshot the starting array length, read element values
live by index, honor live
array.lengthtruncation for later visits, and pass(value, index, array)plus an optionalthisArg - array callback helpers currently support guest callbacks, built-in callbacks, and promise-valued callback results reached from an async guest boundary
- synchronous host suspensions from array callback helpers fail closed with a
runtime
TypeError Array.fromaccepts the supported iterable surface and an optional synchronous map function plusthisArg; inside async guest flows, guest map callbacks may yield promise values for downstream helpers such asPromise.allArray.ofalways creates a fresh guest array from its arguments and does not expose the special single-length constructor behavior from full JavaScriptArray(...)andnew Array(...)follow JavaScript's single-length constructor behavior for one numeric argument, including explicitRangeErrorrejection for invalid lengthsArray.prototype.concatreturns a fresh guest array, spreads only actual guest array arguments, and appends every other value as a single elementArray.prototype.attruncates the requested index, supports negative offsets from the end, and returnsundefinedwhen the computed index is out of rangeArray.prototype.lastIndexOfmirrors the conservative equality and hole treatment used byindexOf, but searches from right to leftArray.prototype.reversemutates the original array in place, preserves hole positions, and returns the same array valueArray.prototype.fillmutates the original array in place over the requested start/end range and preserves holes outside that rangeArray.prototype.splicemutates the original array in place, returns a fresh guest array of removed elements, and preserves non-index array properties on the mutated receiverArray.prototype.reducethrows a runtimeTypeErrorwhen called on an empty array without an explicit initial valueArray.prototype.reduceRightfollows the same callback and empty-array failure rules asreduce, but traverses present elements from right to leftArray.prototype.findLastandfindLastIndexfollow the same callback rules asfind/findIndex, including hole visits asundefined, but traverse from right to leftArray.prototype.flatdefaults to depth1when the argument is omitted orundefined, truncates other depth values to integers, and flattens only actual guest arraysArray.prototype.flatMapuses the same callback rules as the other array callback helpers and flattens only one returned guest-array layerArray.prototype.sortsorts in place, returns the original array value, and accepts either the default string ordering or a synchronous comparatorObject.assignmutates and returns the original target, copies enumerable properties from later plain-object or array sources in the runtime's documented helper enumeration order, and skipsnull/undefinedsourcesObject(value)preserves existing supported object-like guest values and boxes primitive strings, numbers, and booleans into conservative wrapper objects; boxed strings expose the documented string helper surface, while boxed numbers and booleans exposetoString()/valueOf()- supported guest functions, bound functions, and built-in callables expose
own
name/length, inheritconstructorpluscall/apply/bindfrom the shared callable surface, and expose the usual constructible-function.prototypeproperty where applicable; guest functions and supported constructor values also support custom enumerable string-keyed properties, and anonymous guest functions infer names from supported binding and property-key writes - object literal spread uses the same plain-object and array source surface as
Object.assign, always targets a fresh plain object, skipsnull/undefinedsources, and throws a runtimeTypeErrorfor other source values Object.fromEntriesaccepts the supported iterable surface and expects each produced item to be a guest array pair- binary
inchecks the runtime's currently exposed property surface without introducing user-defined prototype lookup or descriptor semantics - for plain objects and built-in object records,
insees stored string-keyed properties plus the explicitly documented virtual members already exposed by the runtime - for arrays,
inrecognizes in-bounds numeric indices,length, custom string properties, and the documented helper methods - for
Map,Set, guest iterators, promises, and the supported constructor functions,inrecognizes only the members that the runtime already exposes directly on those values - primitive right-hand sides for
infail closed with a guest-safe runtimeTypeError Object.createis exposed only as an explicit runtimeTypeErrorbecause full prototype semantics remain deferredObject.freezeandObject.sealare exposed only as explicit runtimeTypeErrors because property descriptor semantics remain deferredMap.prototype.forEachandSet.prototype.forEachsupport synchronous guest callbacks plusthisArg, visit entries appended during active iteration, and fail closed for synchronous host suspensionsString.prototype.split,replace,replaceAll,search, andmatchaccept string-coercible patterns and realRegExpinstances- primitive strings expose
length, numeric index reads,constructor,toString(), andvalueOf()in the conservative helper surface; primitive numbers and booleans exposeconstructor,toString(), andvalueOf() String.prototype.trimStart,trimEnd,padStart, andpadEndare supported on primitive strings and boxedStringwrappers in the conservative helper surfaceString.prototype.indexOf,lastIndexOf,charAt,at,repeat, andconcatare available on primitive strings in the conservative helper surfaceString.prototype.matchAllreturns a guest iterator over match-result arrays;RegExpinputs must be global- callback replacements for
replace/replaceAllare supported for guest callables, built-ins, and other synchronous guest-callable values - string replacement callbacks are synchronous-only; host suspensions fail
closed with a runtime
TypeError - replacement strings support
$,#x26;,,MustardScript — Like JavaScript, but smaller ,$1...$99, and#x3C;name>template expansion forRegExpmatches String.prototype.replaceAllrequires a globalRegExpwhen the search value is aRegExp- supported
RegExpflags areg,i,m,s,u, andy; unsupported flags fail closed with a runtimeSyntaxError String.prototype.matchreturns eithernull, a guest array of matched strings for globalRegExppatterns, or the first-match array for non-global patterns, with guest-visibleindex,input, and optionalgroupsproperties on that result arrayDate.now()reads the host wall clock as integral epoch milliseconds,new Date(value)currently supports zero arguments or exactly one numeric, string, or existingDatevalue, supported string inputs are currentlyYYYY-MM-DDplus RFC3339 timestamps withZor explicit numeric UTC offsets,Date.prototype.getTime()returns the stored integral epoch milliseconds,toISOString()andtoJSON()render UTC RFC3339 timestamps across the full ECMAScript time-clip range with signed six-digit years when required, and the documentedgetUTC*accessors expose UTC year/month/day/hour/minute/second fields while returningNaNfor invalid datesNumber.parseInt,Number.parseFloat,Number.isNaN,Number.isFinite,Number.isInteger, andNumber.isSafeIntegerare available as conservative static helpers onNumber; the corresponding global aliases plusNaN/Infinityare also installed onglobalThisNumber.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,EPSILON,MAX_VALUE,MIN_VALUE,POSITIVE_INFINITY,NEGATIVE_INFINITY, andNaNare exposed as conservative static constants onNumberIntl.DateTimeFormatandIntl.NumberFormatare available in a narrow deterministic subset: locale support is currently limited toen-US,DateTimeFormatcurrently accepts onlyUTCtime-zone formatting plus the documented numeric / two-digit date-time fields, formats hour-bearing output with the defaulten-US12-hour clock plusAM/PM, and rejects any other option keys explicitly;NumberFormatcurrently supports onlydecimal,percent, andcurrencyformatting withUSDas the only supported currency code and rejects any other option keys explicitlyMath.PI,E,LN2,LN10,LOG2E,LOG10E,SQRT2, andSQRT1_2are available as numeric constants onMathMath.exp,log2,log10,sin,cos,atan2,hypot, andcbrtare available as pure numeric helpers over the supported number surfaceMath.random()draws host entropy and returns a finitenumberin the half-open range[0, 1); values are intentionally nondeterministic, are not seedable or reproducible across runs or resumes, and are not a cryptographically strong API contract- structured host arrays may be sparse; hole positions are preserved across the boundary in both directions up to 1,000,000 elements
- direct
Date()calls, multi-argumentnew Date(...), locale-specific date strings outside the documentedDateparsing surface, unsupportedIntllocales or options, and returningDatevalues across the structured host boundary all fail closed - real
RegExpinstances supportsource,flags,global,ignoreCase,multiline,dotAll,unicode,sticky,lastIndex,exec, andtest - symbol-based match/replace protocol hooks and full ECMAScript
RegExpparity remain deferred