Conformance and safety status

The Language Reference describes the language as designed. This page records what the released compiler enforces today, so you know which guarantees you can rely on and which rules you must keep yourself.

Everything below was observed by compiling and running a probe program. Three compilers are compared:

  • 0.14.6 — the current release of the self-hosted compiler;
  • 0.14.7 — the next release of the self-hosted compiler (branch release/0.14.X), which closes the gaps listed here;
  • Seed — the C++ bootstrap compiler, 0.13.18.

Status values:

  • Enforced — violating the rule is a compile error.
  • Checked — violating the rule is detected at run time.
  • Not enforced — the compiler accepts the program; the behaviour is described. Treat these as rules you must follow by hand.
  • Internal error — the compiler stops in its back end without a source position, instead of reporting a diagnostic.

Compile-time rules

Rule0.14.60.14.7Seed
Every function declares a return typeEnforcedEnforcedEnforced
A value function returns on every pathEnforcedEnforcedEnforced
The number of returned values matches the declarationEnforcedEnforcedEnforced
An undefined name is an errorEnforcedEnforcedEnforced
Argument count and argument types match the calleeEnforcedEnforcedEnforced
The returned value's type matches the declared typeEnforcedEnforcedEnforced
A class implements every method of its interfacesEnforcedEnforcedEnforced
An unknown command-line option is an errorEnforcedEnforcedEnforced
A condition is a bool or a number (if n { } with int n is n != 0 from 0.16.0; up to 0.15.x an error); a string, an array or an object is an errorInternal errorEnforcedEnforced
Implicit narrowing is rejected (long→int, int→byte, double→int)Not enforcedEnforcedEnforced
A private field is inaccessible from outside its classNot enforcedEnforcedEnforced
A private method cannot be called from outside its classNot enforcedEnforcedNot enforced
An abstract class cannot be instantiatedNot enforcedEnforcedEnforced
A final method cannot be overridden; a final class cannot be extendedNot enforcedEnforcedEnforced
break only inside a loop or switch; continue only inside a loopNot enforcedEnforcedEnforced
A variable cannot be declared twice in one scopeNot enforcedEnforcedEnforced
string + int is a type errorNot enforcedEnforcedEnforced
A const local or parameter cannot be assigned, incremented or decrementedNot enforcedEnforcedNot enforced
A const field can be assigned only by a constructor of its class (from 0.16.0 also static, bare-name, super.v, delete and multi-assignment writes; see below)Not enforcedEnforcedNot enforced
Two functions of one file cannot share an identical signatureNot enforcedEnforcedNot enforced
No statement may follow a return in the same blockInternal errorEnforcedNot enforced

The released 0.14.6 is less strict than the seed on eight rules. 0.14.7 closes all of them and enforces five rules the seed never did.

The rules in detail

Narrowing needs a cast. A number may be stored into a numeric type that can hold every value of the source type, never a smaller one. Write the cast when you mean to narrow:

long big = 5000000000
int n = big          // error from 0.14.7 — 0.14.6 stores 705032704
int m = (int)big     // explicit: accepted everywhere

A literal is exempt when its value fits the target, so ordinary initializers need no cast:

byte b = 200         // fits
short s = -5         // fits
uint u = 3144134277  // fits
float f = 1.5        // a float literal may initialize a float
byte c = 300         // error: 300 does not fit a byte

Container sizes are pointer, which is wider than int:

int n = (int)list.size()

From 0.15.0 the same rule covers every argument of a call (take(aLong) for an int parameter is an error), a signed value into an unsigned type needs a cast at any width (uint u = anInt, ulong n = anInt, and uint u = -1), and comparing a signed with an unsigned integer is an error unless the signed type holds every unsigned value (see the Language Reference §3.1.4). Up to 0.14.x an argument narrowed silently and a negative value became a huge unsigned one.

One conversion remains implicit on every compiler: any value may be assigned to a bool.

const protects the variable, not the object. Assigning to a const local or parameter, or applying ++/-- to it, is an error from the next release. Writing a field through a const reference (p.x = 1) is allowed: const does not make the object immutable. A field that is itself declared const is the exception: it is assigned by a constructor of its class and is read-only everywhere else. From 0.16.0 that rule covers every way of writing the field. A static const field is set by its initializer alone: K.A = 2, K.A += 1, A++ inside the class and a write in a constructor are errors. An instance const field is set once, by a constructor of the class that declares it, on its own object (this.v = … or the bare v = …), and only when the declaration has no initializer. Writing it on another object (o.v = …), from a subclass constructor (super.v = …), over an initializer, or with delete is an error. Up to 0.15.x only obj.v = … outside a constructor was rejected. From 0.16.0 a multi-assignment follows the same rule for each receiver: a, k = two() with k a const local, parameter or field is the same error, and a constructor may still set its own unset const field this way. Up to 0.15.x the receivers of a multi-assignment were not checked.

const int k = 1
k = 2                // error from 0.14.7 — 0.14.6 stores 2

Field initializers are checked, from 0.16.0. An initializer is checked like the initializer of a declaration (int f = "abc" and int f = aLong are errors). A static field's that is a constant — literals, enum entries, static const fields and the operators and casts over them (static const int B = A * 2 + 1) — is folded into the field's initial value, and a constant that overflows its type or divides by zero is an error. Any other one (static int n = compute()) runs on the first use of such a field of its class. Up to 0.15.x (the v0.15.2 seed included) an initializer was resolved without these checks and never emitted: the field started at its zero value.

private is per class. A private field can be read and written, and a private method called, only from the class that declares it.

A top-level private is per file, from 0.16.0. A private function or type (class, struct, interface, enum) declared outside a class can be used only in the file that declares it. A use from another file, of the same namespace or of one that imports it, is an error ('h' is private to 'parts.fly': a private function or type can be used only in the file that declares it). Two files of one namespace may each declare a private function or type of the same name: they are two definitions, each used by its own file, with distinct symbols in the compiled program. A private name that matches a name the whole namespace sees is still a duplicate definition. Up to 0.15.x (the v0.15.2 seed included) a top-level private was parsed and not checked: any file that saw the namespace could call the function or name the type, and two same-named private functions in two files of a namespace compiled to one symbol, so which body ran depended on the link order. The symbol of a private function or type now carries its file: the base name, or, for the source files of one namespace that share a base name (a/p.fly and b/p.fly), the path that tells them apart. A library whose public generic code uses a private function (the header-private warning) and the programs using it must be compiled by the same release line.

A declaration without a modifier is per namespace, from 0.16.0. A function or a type (class, struct, interface, enum) declared outside a class without a modifier can be used only in its namespace; public is what opens it to the others. A call or a type use from a file of another namespace is an error that names the namespace ('inner' is not public in namespace 'lib.util': a function or type without a modifier can be used only in its namespace), whether the name is written through an import prefix, by its full path, or bare after import ns.name or import ns.*. A namespace is its full name (lib and lib.util are two), and the files with no namespace are one namespace like any other. The check is on the written name: a value of such a type returned by a public function can be used, with its public members, from any namespace. Up to 0.15.x (the v0.15.2 seed included) the missing modifier was not checked inside a build: every namespace could call the function or name the type. Across packages nothing changes: a library header declares only what is public.

protected is per class hierarchy, from 0.16.0. A protected field or method (constructors included) is reachable from the class that declares it and from every class derived from it, through any receiver; anywhere else it is an error ('v' is protected in 'Base': it can be accessed only from 'Base' and the classes derived from it). protected may be written only on the methods and attributes of a class: on a function, a variable, a type or a member of an interface, struct or suite it is an error. From 0.16.0 both private and protected are also checked on static members (A.count, A.make()), on super.v, and on new with a non-public constructor. Up to 0.15.x protected was parsed and ignored (every access compiled), and a private static member could be reached from outside its class.

A suite is not subject to visibility, from 0.16.0. Inside a suite declaration none of the three checks above applies: a private or protected member, a private function or type of another file and a function or type without a modifier of another namespace are usable, in the namespace the suite declares and in those its file imports. The freedom belongs to the suite declaration: a function beside it in the same file and a test {} block are ordinary code. A name that is private to two files of a namespace (same parameter types, for a function) is an error inside a suite too ('pick' is private to 'one.fly' and to 'two.fly': inside a suite the name does not say which file is meant). Code with no namespace is outside a suite's reach: the default namespace cannot be imported. Up to 0.15.x (the v0.15.2 seed included) a suite reached all of this only because the checks were missing.

this is only a receiver in a constructor, from 0.16.0. In a constructor and in an instance field initializer this may read or set a field and call a method (this.x, this.x = v, this.m()); assigning it, passing it as an argument, putting it in an array value or comparing it is an error ('this' can only be a receiver (this.x, this.m()) in a constructor or a field initializer): a constructor that fails releases its object, and a copy of this kept elsewhere would point at released memory. Not covered: a method the constructor calls can still store this. Up to 0.15.x (the v0.15.2 seed included) this was an ordinary value there.

The files of one namespace see each other without an import, from 0.16.0. A file declaring namespace N uses the classes, functions and enums of the other files of N by their bare names; the compiler reads those files from the project's sources because N is the file's own namespace. Up to 0.15.x (the v0.15.2 seed included) they were read only when something imported N: a file of N that used a sibling's class without import N.C failed with unknown type 'C'. Code the seed compiles keeps its imports.

void is only a return type, from 0.16.0. void is written as the return type of a function or a method and nowhere else: a variable, a parameter, a field, an array element, a generic argument or one value of a multi-return declared void is an error ('void' is not the type of a value: it is written only as the return type of a function or method). Up to 0.15.x (the v0.15.2 seed included) void x and void a compiled with only an unused-variable warning; the seed crashes on some of these forms instead of rejecting them.

A handle does not return on every path, from 0.16.0. A failure in the body of a handle skips the rest of it, a final return included, so a function whose body ends in a handle needs a return after it, or it is an error ('h' must return a value on every path). Up to 0.15.x (the v0.15.2 seed included) a handle whose body ended in return counted as returning, and on a failure the function silently returned zero (fly-lang/fly#342).

Expressions whose types do not fit are errors, from 0.16.0. Up to 0.15.x (the v0.15.2 seed included) each of these compiled, then printed garbage or stopped at run time (fly-lang/fly#338):

ProgramFrom 0.16.0
?: with two branches of no common type (int x = c ? 1 : "two")the two branches of '?:' have no common type: 'int' and 'string'
==, != and the other comparisons on two structs (a compare of their addresses)two structs ('P') cannot be compared with this operator: compare their fields
A signed and an unsigned integer of one width in arithmetic (aUint + anInt, an overflow at run time)a signed 'int' and an unsigned 'uint' cannot be mixed in arithmetic, unless the signed side is a non-negative literal
fail with two codes, messages or objects, or a float, bool, enum, struct or array operandfail takes at most one … / a 'double' cannot be an operand of fail
fail with a code that does not fit an int (fail 3000000000 exited 0)the code of a fail is an 'int': a 'long' needs a cast

s += t on a string, which 0.15.x refused, appends.

Redeclaration versus shadowing. Declaring a name twice in the same scope is an error; declaring it again in a nested block shadows the outer variable and is allowed.

Overloads must differ in their parameters. Two functions of the same file with the same name and parameter types are rejected. The return type does not distinguish overloads.

Invalid programs are compile errors, not internal errors (from 0.16.0). These used to pass the checks and stop the compiler in the LLVM verifier (backend module verification failed, with no position), the v0.15.2 seed included; each is now an error at its place in the source, or correct code:

ProgramFrom 0.16.0
A statement after break, continue, or a nested { } block that ends in a jumpunreachable code, as after a return
An assignment, a compound assignment, ++ or -- on something that is not a variable, a field or an array element (3++, f() = 2, x + 1 = 2, E.A = E.A)cannot assign to …; null = null and this = other, accepted up to 0.15.x, too
void main(const int x)'main' takes no parameters
==, < and the other comparisons on arraysthis operator cannot be applied to operands of type 'array' and 'array'
% on float or doublethe remainder with the sign of the dividend (7.5 % 2.0 is 1.5)
!n on a numbera bool, n == 0

A call through a method table never guesses (from 0.16.0). A call through a class or interface reference reads the method from the receiver's method table. If the compiler finds no entry for the method there, that is a defect of the compiler, and it stops with internal: method 'm' has no slot in the vtable of 'C' (or no entry in the itable of 'I') instead of emitting the call. Up to 0.15.x (the v0.15.2 seed included) such a call used the first entry of the table and ran another method without a word (fly-lang/fly#333 for interfaces, fly-lang/fly#352 for classes).

Declarations the Language Reference forbids are errors (from 0.16.0). Up to 0.15.x, the v0.15.2 seed included, each of these compiled; some then ran the wrong method or read garbage. Each is now an error at the member, base or modifier at fault (fly-lang/fly#340):

DeclarationFrom 0.16.0
An override, or a method implementing an interface method, with another return typeerror, with a note at the method it overrides (up to 0.15.x the call through the interface read the wrong type; through a base class it ran the base's method)
Two fields with one name; two methods or two constructors with the same parameter types (also when only the return type differs); two parameters with one name; an enum constant twice… is already declared in '<type>' / … is declared twice, with a note at the first (up to 0.15.x the last of three int k() won the call)
A struct extending a class or an interface; an interface extending a class; anything extending an enum, int, string or its own type parameter; a base listed twice'S': a struct extends only a struct, not the class 'A' and the like (up to 0.15.x a struct extending a class read garbage)
A reserved word as the name of an enum or of a constant (enum while { new })'while' is a reserved word and cannot be used as a name
A field in an interface; an interface method with a body; an abstract method with a body; a method without a body in a class that is not abstract; a class final and abstracterror naming the rule
class A<> {}; private private, public private; an empty enum E { }error at the >, at the second modifier, at the enum's name

A method may declare several return types, as a function does (int, int split(const int v), q, r = p.split(47)): an instance or static method, an interface method, an override, called on the class, through a base class or an interface, and from a -L library, whose header lists every return type. Up to 0.15.x such a method was a parse error (expected an identifier here) (fly-lang/fly#349).

Known compiler defects

ProgramResult
A build of more than one source file (fly --suite over a tree, --lib, a module pulled in by an import)0.14.6: a semantic error outside the first input file is reported with the name, line and column of the first file. Compile the single suite (--suite=<Name>) to get the right position. Fixed in 0.14.7.
A class or interface that is its own base, a struct that holds itself by value, or deep nesting (about 450 parentheses, or a chain of about 1,500 operators, on Windows)Up to 0.15.x (the v0.15.2 seed included): fatal error: stack overflow. Fixed in 0.16.0: a compile error that shows the cycle, and documented limits of 256 levels of nesting and 4096 operators per expression (Language Reference 8.8).
A struct that reaches itself through an unsized array (struct P { P[] more })Up to 0.15.x (the v0.15.2 seed included): fatal error: stack overflow, with --no-output too. Fixed in 0.16.0: it compiles, and its members are released as deep as the data goes (Language Reference 6.2) (fly-lang/fly#351).
An interface with two or more bases (interface Widget : Resizable, Serializable), called through itUp to 0.15.x (the v0.15.2 seed included): only the first base counted, and a call to a method of another base ran a different method. Fixed in 0.16.0: the interface has the methods of every base (Language Reference 6.3) (fly-lang/fly#333).

Warnings

From 0.15.0 the self-hosted compiler reports unused variables and imports, shadowed names, integer-to-float conversions that may round, and a switch over an enum that misses values (see the CLI reference); from 0.16.0 also a parameter without const that the body never writes (missing-const). Up to 0.14.x it emitted no language warning.

Two command-line options are accepted but have no effect yet: --ftime-report and --mthread-model. In 0.14.6 they are ignored silently; from 0.14.7 the driver prints a warning saying so, which -w suppresses. --debug-symbols was the third until 0.14.8, which emits DWARF (line tables, parameters and locals; not yet the fields of a class).


Run-time behaviour

OperationBehaviour
Array index out of rangeChecked. A failure with code 2989, which handle can intercept; uncaught, the program stops with error 2989: index out of range at main.fly:4:5 (the message and position from 0.16; before, error 2989 alone) and exit code 2989 (173 as a POSIX shell sees it).
A sized array declared with a negative size (int[n] a with n < 0)Fails from 0.16.0, in every build and at every optimization level: code 2992, negative array size at main.fly:4:5, before anything is allocated; a handle catches it. Up to 0.15.x: an invalid memory access, or an array of length -1 (fly-lang/fly#320).
A sized array whose bytes do not fit the address space, or that the system cannot allocateStops from 0.16.0: error 134: out of memory at main.fly:4:5, exit code 134. Up to 0.15.x: an invalid memory access on the null buffer, and a byte count that overflowed (long[n], n near 2^61) wrapped to a small buffer that indices up to the size reached past. Other allocations (strings, objects, fly.mem) do not check yet (fly-lang/fly#359).
Access through a pointer that points nowhere (fly.mem reads and writes)Not checked: pointer is the unchecked part of the language. From 0.16 the program prints fatal error: invalid memory access at address 0x… before it ends; the exit code stays the system's (0xC0000005 on Windows, 139 for SIGSEGV on Linux and macOS), and a debugger, a core file or a crash dump see the fault as before. Up to 0.15.x: no message.
Stack overflow (recursion without end)Not checked. From 0.16.0 the main thread reserves 8 MB of stack on every platform (up to 0.15.x 1 MB on Windows, fly-lang/fly#350). From 0.16 the program prints fatal error: stack overflow before it ends, with the system's exit code (0xC00000FD on Windows, 139 on Linux and macOS). The main thread only: on Linux and macOS a fault within 64 MB below main's frame is reported as a stack overflow, any other one as an invalid memory access. Up to 0.15.x: no message.
Local variable without initializerDefined: it holds the zero value of its type. A struct then takes the initializers of its fields (from 0.16.0).
A field declared with an initializer (int f = 6, static int count = 11)From 0.16.0: an instance field's initializer runs when the object is created, after the zeroing and before any constructor, inherited fields first, whether or not the constructor calls super(...); a failing initializer fails the new. A static field starts at its constant initializer; an initializer that is not a constant runs on the first read or write of such a field of its class, with the others of the class, in declaration order — a failing one fails that access and runs again at the next, and one that reaches a field of its class not yet initialized fails with code 2990 (static initialization cycle). Up to 0.15.x the initializer was ignored and the field started at its zero value.
Integer overflow of +, -, *, ++, --, unary - (signed and unsigned)Checked from 0.15.0, in every build: error 134: integer overflow in '+' at main.fly:2:5. Wrapping is explicit: math.wrapAdd and its siblings. Not checked: pointer arithmetic, shifts, bitwise operators, casts between integer types. Up to 0.14.x: wraps silently.
A shift count negative or not less than the width of the type (1 << 32, 1 << -1)Fails from 0.16.0, in every build and at every optimization level: code 2990, shift count out of range at main.fly:4:12; a handle catches it. Up to 0.15.x: undefined (the masked count at -O0, the optimizer's choice above it).
A cast from float/double to an integer type the value does not fit, or of NaN ((int)1.0e20)Fails from 0.16.0, in every build and at every optimization level: code 2991, conversion out of range at main.fly:4:12; a handle catches it. A value in range rounds toward zero; an unsigned target takes (-1, MAX + 1). Up to 0.15.x: undefined (the minimum int at -O0, 0 at -O3).
An overflow between constants, a division or remainder by the constant 0, a constant shift count out of range (2147483647 + 1, x % 0, 1 << 40)Compile-time error from 0.16.0 (integer overflow in '+': the result of these constants does not fit 'int', division by zero in '%', shift count 40 out of range for 'int'). The operator's type is its operands': long l = 2147483647 + 1 is the same error, (long)2147483647 + 1 is 2147483648. Up to 0.15.x (the v0.15.2 seed included) an overflow between constants wrapped silently (65536 * 65536 was 0), and the other two stopped only at run time.
Integer division or remainder by zero (/, %, /=, %=)Checked from 0.15.0, in every build: the program stops with error 134: division by zero at main.fly:2:5 and exit code 134. Up to 0.14.x: abnormal termination, with no message.
Signed minimum value divided by -1 (-2147483648 / -1)Checked from 0.15.0: error 134: integer overflow: the minimum value divided by -1 at …. % by -1 is 0.
Floating-point division by zeroIEEE 754: infinity or NaN, no trap.
A comparison with NaNIEEE 754: == < <= > >= are false, != is true (the opposite of ==). Up to 0.15.x NaN != NaN was false.
float arithmetic32-bit IEEE 754 single precision. Up to 0.15.x every float was a 64-bit double.
A bool cast to a number ((int)b, (double)b)1 for true, 0 for false, in every numeric type; false < true. Up to 0.15.x true became -1 and true > false was false.
< <= > >= between stringsFrom 0.16.0 byte by byte, unsigned, a prefix first: the order of str.compare. Up to 0.15.x they compiled as ==.
Method call or field access on a class or interface reference that is null or was never assignedChecked from 0.15.0, in every build (release included): the program stops with error 134: null reference: calling 'size' on a null 'Box' at main.fly:16:5 (or accessing field 'v' of …) and exit code 134. Calls through this are not checked: the caller already did. Up to 0.14.x: segmentation fault, with no message.
Use of an object after delete x through another referenceFrom 0.16.0 a method call stops with error 134: use of a deleted 'Box' (exit 134), also through an interface; a field access is not checked, but reaches only an object of the same class: a freed slot is reused by the same class alone (fly-lang/fly#314). Up to 0.15.x: the call followed freed memory, and a field access could reach an object of any class that reused the slot.
Use of an object after delete xChecked from 0.15.0 through the same variable: delete sets it to null, so a later use stops on the null-reference trap. Another variable that still points at the object: see the row above.
Use of an object after calling its free() directlyNot checked.
A class instance created with a plain new that is never deletedFrom 0.16.0 leaving the scope of its variable releases nothing (see the Language Reference §6.6), and at the end of main the object is reported on stderr (warning: N objects not deleted (B B) and one line per class) and released — its free() runs, an object before the objects its fields refer to, objects that refer to each other once each. What a static field refers to (and what is reached from it through fields) is released too and not reported. The exit code does not change; a run-time trap or a crash skips the report. In 0.15.x a local created with new that had not escaped was released at the end of its scope, and the rest leaked silently. There is no garbage collector.
A second delete of an object through another reference (b = a, delete a, delete b)Checked from 0.16.0: error 134: double delete of a 'Node' at main.fly:4:5, exit code 134, as long as the freed slot has not been reused. Once a new of the same class has taken it, the old reference points at the new object and the second delete deletes that one, with no error (only an object of the same class can be reached: fly-lang/fly#314, fly-lang/fly#334). Up to 0.15.x: undefined (a double free).
A delete reaching the object being deleted from its own destructor (a.next = a, or a cycle, with delete() { delete this.next })Checked from 0.16.0: error 134: double delete of a 'Node' at the inner delete, exit code 134: the object is dying while its destructors run (fly-lang/fly#334). A recursive destructor over a long chain still overflows the stack (a few tens of thousands of nodes): the Language Reference shows the loop that deletes any length.
The object of a fail consumed by handleDeleted from 0.16.0 (the error owns it). Up to 0.15.x: dropped from the error, never released.
A free() that failsAn ordinary failure from 0.16.0: after delete (the object still released, the variable null), in the release at the end of main (it sets the exit code when main ended cleanly). One that fails while another failure is in flight (the elements of a sized array that failed, the release at the end of a main that failed) does not replace it: the first stays the failure and the later one is attached to it — main prints it as also: error 43: free, a handle consumes it with the first. Up to 0.15.x: not checked after delete (it surfaced at a later call or at the end of main), dropped in a cleanup or at the end of main, and at the end of a new unique scope it overwrote the failure in flight.
Locals of a handle block or a suite case (and of the blocks in them) left by a failureStrings and arrays released from 0.16.0, as a return releases them, innermost scope first. Objects are never released by a failure: the program deletes them (fly-lang/fly#321). Up to 0.15.x: left behind (strings and arrays leaked).
new unique, new shared, weak hCompile errors from 0.16.0 that name the replacement (new and an explicit delete): 'new unique' was removed from the language: …. From 0.15.0 to 0.15.x: one owner released at the end of its scope, reference-counted holders, weak references; the v0.15.2 seed still accepts new unique and new shared.
A destructor delete()From 0.16.0: run by delete only, on the dynamic class, then the base classes' destructors up the hierarchy; one that fails is a failure of the delete (the bases still run, the object is freed, later failures attached). Not run by a new that fails, nor by the release at the end of main. Two destructors, a modifier, parameters, a return type, or a destructor in a struct, an interface or an enum are compile errors. In 0.16.x a class with no destructor in its hierarchy keeps free(); the v0.15.2 seed does not parse destructors.
The fields of an object deleted, or of a new that failedNot released from 0.16.0: delete runs the class's destructor (or free()), which deletes them, and a constructor that fails after it set one deletes it itself. Up to 0.15.x the fields filled with new unique, new shared or weak were released with the object.
A fail (or an index out of range) written directly in a suite caseEnds the case from 0.16.0, like a failing call: reported on the case's own line, the next case runs. Up to 0.15.x (and in the v0.15.2 seed): it returned from the test method, reported as body ... FAIL(...), and the method's later cases were skipped.
Two files with no namespace declaring a class, a function or an enum of the same nameAn error from 0.16.0: the files without a namespace are one namespace, the default one, with the rules of every namespace. They are read together (a file with no namespace brings in the others under the source directories), they see each other's declarations without an import, and a function (same name and parameter types) or a type defined in two of them is reported on the second with a note at the first: 'one' is already defined in the default namespace …. A private function or type belongs to its file, so two files may each have one of the same name. Up to 0.15.x (and in the v0.15.2 seed) each such file was a namespace of its own and only the entry was read; compiled together (--lib, --suite over a tree), two files declaring the same name shared their symbols: the two classes one initializer and one release helper (an object released as the other class, or a crash), the two enums one name table, and of two functions in files with the same base name (a/p.fly, b/p.fly) the second was renamed without a word.
A program with a main whose namespace also holds a suite (main.fly and test/XSuite.fly, both in one namespace or both without one)Runs its main from 0.16.0. A plain build reads every file of the namespace, the suite's too; up to 0.15.x a suite among the compiled files replaced the entry, and the program ran the tests instead of main. Outside test mode a suite is the entry only when the build has no main.
A multi-return function called in its full form (divmod(17, 5, q, r)) from a file with a namespaceResolves from 0.16.0. Up to 0.15.x the call was refused (no function or method named 'divmod' matches this call) when the function was in a named namespace: it was listed twice, by its file and by its namespace, and taken for two candidates. It resolved only in a file with no namespace.
Two source files with the same base name in different directories, each with its namespace (a/p.fly, b/p.fly), or a file in a subdirectory named like the entry fileBoth read from 0.16.0: a source file is identified by its path. Up to 0.15.x (and in the v0.15.2 seed) the files already read were listed by base name and the second was skipped without a message: what it declared was missing (unknown type 'P', cannot find 'b' in this scope).
Two source files of one namespace (or both with none) with the same base name in different directories (a/p.fly, b/p.fly), each declaring a private function, class or enum of the same nameTwo definitions from 0.16.0, each used by its own file: a private belongs to its file whatever the file is called. The symbols of such files carry the part of the path that tells the files apart (a/p, b/p), every other file keeps its base name, and the names do not depend on where the source directory is. Up to 0.15.x (and in the v0.15.2 seed) a top-level private was not kept to its file, and same-named ones compiled to one symbol.
Two namespaces that read the same with _ for . (a.b_c and a_b.c), or that end with the same segment (x.z and y.z), each declaring a function or a class of the same nameTwo definitions from 0.16.0: a symbol carries the namespace as written, with its dots (_F5a.b_c1f…, vtable.x.z.P), and a file tag starts after an empty segment (app..f_p), which no namespace has. Up to 0.15.x (and in the v0.15.2 seed) the segments were joined with _ and a class symbol carried the last segment only: the second function was reported as already defined, namespace app._f_p spelled the private symbols of p.fly in namespace app, and two libraries declaring x.z.P and y.z.P failed to link (duplicate symbol: vtable.z.P). Every symbol of a namespace with more than one segment changed.
A library declaring two overloads that differ by which type of one short name a parameter has (h(left.P) and h(right.P), k(Box<int>) and k(Box<string>), f(A, int) and f(A_i)), called from a program through the header; a generic specialization next to a class written like its old name (Box<int> and class Box_int)Each call reaches its own function, and the two classes are two, from 0.16.0: in a symbol a parameter of class, struct or enum type is its full name with the length in front (_C12probe.left.P), and a specialization is spelled as it is written (Box<int>, Pair<int,probe.left.P>), which no class name can be. Up to 0.15.x (and in the v0.15.2 seed) the parameter was the short name alone (_CP, _CBox) and the two overloads were one symbol: inside one program the second was renamed by a counter and the calls worked, across a library the program failed to link (undefined symbol: …h_CP_i.8) as soon as the library held another such pair. A specialization was Box_int: next to a class of that name the two shared one initializer and one release helper (new Box_int() ran the field initializers of Box<int>), and an argument of class type added a number that changed with the path the source directory was given as. Every symbol with a class, struct or enum parameter changed, and every symbol of a specialization: a library built by 0.15.x does not link into a 0.16.0 program.
A program using, through -L, a library class with private, protected, static, const, final or abstract membersThe rules of the source from 0.16.0: the header writes each field and each public or protected method with its modifiers, and a class with abstract or final. A private field is refused ('secret' is private to 'Box'), a protected member is open only to a class derived from it, a static field is the library's one variable, reached through the class. Up to 0.15.x (and in the v0.15.2 seed) the header wrote a field with no modifier, no protected method, and neither static nor final: the program read and wrote private fields, a subclass could not call a protected method, a static field could not be reached (cannot find … in this scope), and const, final and abstract were not applied.
A program calling, through -L, a public method of a library class that also declares private, protected or no-modifier methods or constructors — and a class the program derives from itThe method the source reaches from 0.16.0: the method table holds the methods that are not private (no constructor, no private method: both are called directly), and the header lists exactly those, in declaration order, so both sides number the slots alike. A method or constructor without a modifier is in the header and is called as from source. Up to 0.15.x (and in the v0.15.2 seed) every method and constructor took a slot and the header listed only the public ones: a call through the header ran another method with no diagnostic (v.get() ran half()), a class derived in the program crashed, and a method without a modifier was no function or method named … matches this call.
new on a library class whose constructors are all private, through -LAn error from 0.16.0, the one of the source ('Only' is private to 'Only'): the header says private Only(). Up to 0.15.x (and in the v0.15.2 seed) the header declared no constructor, the reader gave the class the default one, and the program compiled.
A library whose public class has a field of a type that is not public (a class, a struct or an enum without a modifier, or private), or names one in a signature or as a base, used through -LUsable from 0.16.0: the header declares each such type, and the ones it names in turn, with its own modifier; the program reads the header, finds every field where the library put it, and uses a value of the type with its public members. Writing the type's name is the error of the source build ('Helper' is not public in namespace 'lib.shapes', 'Size' is private to 'shapes.fly'). A type nothing in a header names is not declared. Up to 0.15.x (and in the v0.15.2 seed) the header named the type without declaring it and could not be read: unknown type 'Helper'.
An override, or a method implementing an interface method, whose parameter is const where the overridden one is not, or the other way roundAn error from 0.16.0: parameter 'b' differs in 'const' from the method it overrides of 'Sink', with a note at that method. const decides how an argument is passed, and a call through the base is built from the base's method. Up to 0.15.x (and in the v0.15.2 seed) it compiled: the override read its arguments one indirection off, and the program lost the writes through them or ended with invalid memory access.
A private method with the name and parameters of a method its class inherits (from a base class or an interface)An error from 0.16.0: private method 'run' cannot override 'run' of 'Base'. A private method is called directly and never overridden; a subclass may declare one with the signature of a private method of its base, and each class calls its own. Up to 0.15.x (and in the v0.15.2 seed) a private method overrode and was overridden like any other.
A library (--lib) built from two source files with the same base name in different directoriesTwo headers from 0.16.0: the files that share a base name put their namespace in the header's name (a.p.fly.h, b.p.fly.h); with the same namespace, or none, the build stops with an error that names both files. Up to 0.15.x (and in the v0.15.2 seed) both wrote p.fly.h and the first header was lost without a message.
Two functions with the same name and parameter types, or two types (class, struct, interface, enum) with the same name, in one namespaceAn error from 0.16.0, in one file or across files, with a note at the first definition. Up to 0.15.x (and in the v0.15.2 seed) only two functions in one file were reported: across files the program compiled and the link order chose the body, and a type defined twice was accepted.
Two functions whose parameters are classes or enums with the same short name from two namespaces (h(probe.left.P), h(probe.right.P)), or specializations over them (Box<probe.left.P>, Box<probe.right.P>)Two overloads from 0.16.0: a class or an enum type is identified by its namespace and its name, a specialization by its type arguments, and each call picks its own. Up to 0.15.x (and in the v0.15.2 seed) types were compared by their short name: the second function was reported as already defined.
A class value assigned where an unrelated class, or a subclass of its own, is expected (Dog d = new Cat()), or an enum value where another enum isAn error from 0.16.0, in a declaration, an assignment, a return, a field initializer and a struct literal: a class value goes where its class, a base or an interface of it is expected. Up to 0.15.x (and in the v0.15.2 seed) only the kind (class, number, string, enum) was checked, and the program read the object as the wrong class.
A type written with the prefix of an imported namespace of more than one segment (left.P after import probe.left), a dotted new (new left.P(), new probe.left.P()), and a dotted type with an unknown prefix (zzz.P)Resolved from 0.16.0: the prefix expands through the imports, as for a call; an unknown prefix is an unknown type. Up to 0.15.x (and in the v0.15.2 seed) the first two were errors (unknown type, a parse error) and zzz.P silently meant any P in scope.
A local array whose element type is a dotted name (probe.left.P[2] all, left.P[] some = {}), and an enum value or a static member written with a namespace prefix (probe.left.Mode.ON, left.Mode.ON, left.P.count)Resolved from 0.16.0: the array is a declaration (the name after the brackets tells it from an index into a member), and the prefix reaches the values of a type as it reaches the type. Up to 0.15.x (and in the v0.15.2 seed) the declaration was read as an expression or did not parse, and the value was an error ('probe' is a namespace, not a value): the enum or the class had to be imported by name.
A namespace prefix that names a namespace of the program in full and, through an import, another one (util.twice(2) with import probe.util and a namespace util.extra)An error from 0.16.0 ('util' is a namespace and also the import of 'probe.util'), in a call, a type, a new and an enum value; the full name says which. Up to 0.15.x (and in the v0.15.2 seed) the namespace written in full won without a word: the call was no function or method named 'twice', and a library written with the short prefix broke in a program that had a namespace of that name (fly-lang/fly#248).
On Windows, a file or directory whose path is longer than 260 characters (248 for a directory): fly.os.fs (exists, stat, readStr, writeStr, dirRead, dirCreate, rename, del…), and a source file of a build lying that deepReached from 0.16.0: the runtime calls the wide Win32 functions and gives a path that is long once made absolute the \\?\ prefix, whatever the machine's long-path setting; shorter paths go as they are written, and a name is UTF-8 (fly-lang/fly#345, below). Up to 0.15.x (and in the v0.15.2 seed) the ANSI functions were called, which stop at MAX_PATH: the file looked absent, fs reported nothing, and a build went on without the source file — failing later for another reason (cannot find 'a' in this scope), or succeeding without it when nothing referred to it. Still bound by the system: the current directory (env.cwdSet) and the executable a process is started from.
On Windows, starting a process (proc.exec, proc.execCapture) whose command line — the executable and every argument — is longer than 8192 bytesStarted from 0.16.0, up to what Windows takes: 32767 characters (UTF-16 units, the end of the line included). A longer one is a failed start: -1, no child, and execCapture leaves the output file alone. Up to 0.15.x (and in the v0.15.2 seed) the line was assembled in 8192 bytes with no check, and a longer one wrote past them: the program stopped with a heap corruption or an invalid memory access and printed nothing — the compiler too, which starts the linker this way.
On Windows, text that crosses the system: an argument of proc.exec with a space, a tab, a quote or a backslash; the arguments a program reads (env.argsGet); a path, the current directory, the executable's path, an environment variable or a directory entry with letters outside ASCIIAs written from 0.16.0: every argument of a child is quoted with the rules of the Microsoft C runtime and the line goes to the system in UTF-16; a program splits its own command line with the same rules; every text is converted between UTF-8 and UTF-16, never through the ANSI code page. Up to 0.15.x (and in the v0.15.2 seed) only the executable was quoted: -o "out dir/app" reached the linker as two arguments, and a project in C:\Users\First Last or a toolchain under C:\Program Files could not link. A quote counted only at the start of an argument (--x="a b" and \" were not read back), and the text went through the ANSI code page: a name like sörc or José was written as another one, a letter outside the code page as ?.
A source directory the compiler cannot list, or an entry of one it cannot reach (a permission, a path past the system's limits), other than a hidden directoryAn error from 0.16.0: error: cannot read directory '<path>' or error: cannot read '<path>', for fly, fly build, fly test and the header directories (-L); fly fmt prints fmt: cannot read '<path>' and exits with 2. Up to 0.15.x (and in the v0.15.2 seed) the walk skipped it without a message.
Order of the entries fs.dirRead returns, and with it the order in which fly --suite and fly test run the suites of a directorySorted by name from 0.16.0 (byte by byte), the same on every machine. Up to 0.15.x (and in the v0.15.2 seed) the order was the operating system's: two suites of one directory could run, and print, in either order.
fly test with two suite files of one name in two directories (x/FooSuite.fly, y/FooSuite.fly)Two executables from 0.16.0: a suite is named by the path of its file below the project (.fly/test/x/FooSuite, fingerprint .fly/test/.state/x/FooSuite.fp, result line PASS x/FooSuite). Up to 0.15.x a suite was named by its file name alone: the two shared target/test/FooSuite and one fingerprint file, so both were compiled again at every run and the executable left was the last one built.
What fly test compiles into a suite's executable (TopSuite.fly next to the manifest, x/FooSuite.fly and y/FooSuite.fly below)The suite alone from 0.16.0: each suite file is the only entry of its build (fly --test --entry <suite file>), its imports are looked for in the whole project, no other suite's file is read, and a suite file with no namespace does not bring in the other files with no namespace. Up to 0.15.x a suite was compiled with its own directory as the source directory and no entry named, so every suite file in that directory and below was compiled in: t/ASuite also ran t/BSuite and t/sub/CSuite, a suite could not import a namespace declared beside its directory (tests/ → src/), and TopSuite stopped with a type named 'FooSuite' is already defined. --entry with --test/--suite was an error (cannot specify --entry with --test/--suite).
fly with --out-dir and no -o, when the entry file lies in a subdirectory of the sources (fly --src-dir . --out-dir out --suite over test/OneSuite.fly and test/TwoSuite.fly; fly --src-dir proj --out-dir out over proj/main.fly)Builds from 0.16.0: under --out-dir a default name is a name alone — the entry file's stem (out/main), or the source directory's name when several suites share the executable, . being the directory it is (out/myproj). Up to 0.15.x the name kept the entry's path (out/./test/OneSuite.o, out/proj/main.o), which does not exist below the output directory, and the build stopped with error: object emission failed, naming no path; the message now ends with cannot write '<path>'.
The path of a positional Manifest target (new Target("a", "src/a.fly", ""))The file built from 0.16.0: for an executable it is the entry (as --entry), its directory the source directory; it must name a .fly file that exists inside the project, otherwise error: target 'a': path '…' does not exist (no path, is outside the project). Up to 0.15.x only its directory counted: a missing file built the directory's program, two programs in one directory stopped with multiple main() functions, and an empty path built the directory above the project.
fly --entry <file> when another file under the source directories declares a top-level main()Left out from 0.16.0: the named file holds the program's only main(), so a second program needs no namespace of its own next to the first.
fly test over a *Suite.fly file that declares no suiteLeft out from 0.16.0, with skip <path> (no suite). Up to 0.15.x it was built as a program, run, and reported PASS when it exited with 0.
fly init where src/main.fly exists, or with a --name/--version the manifest does not acceptRefused from 0.16.0, exit 3, nothing written. Up to 0.15.x it replaced src/main.fly with the template, and wrote a manifest no command could read.
fly fmt over a path that does not exist or is not a .fly file; a directory below whose name starts with a dot; the comment after the } of a block that spans lines; a switchFrom 0.16.0: an error with exit 2; not entered; left in place; laid out, one label per line and its statements below it. Up to 0.15.x: 0 file(s) reformatted and exit 0; formatted (.fly/ included); moved to the line of the {; left on one line or half expanded. A parse error now names its file.
A struct written into an array: as an element of an array literal (Cell[] cells = {c}), by assignment to an element (cells[0] = c), or read as the item of a for … inCopied from 0.16.0: the fields go into the element, as an assignment between two struct variables copies them, and the item of the loop is a copy of the element. Up to 0.15.x (and in the v0.15.2 seed) the element kept the address of the value instead of its fields and read back as something else, and a for … in over an array of structs could crash; neither was reported.
A struct with a string or array member returned by a method (Pair q = box.get()), stored in a fly.data container (List<S>, Map<K, S>, …), or bound from a brace literal (S s = {a = "x", xs = {1}})Owned from 0.16.0: the method result is the caller's own copy, a container stores, hands out and releases its own copy member by member, and a literal hands its strings and arrays to the variable. Up to 0.15.x a method returning a struct could free stack garbage (heap corruption), a container kept the address of the caller's variable (later changes showed through, delete of the container corrupted the heap), and a literal's strings and arrays were copied and left behind (a leak per declaration).
A multiple assignment whose arguments name its receivers (p, q = swap(p, q) with P, P swap(const P a, const P b))The receivers take the results after the call from 0.16.0: p, q = swap(p, q) swaps. Up to 0.15.x the first result was written into p while swap still read a through it, and both receivers got q's value.
A sized array field (struct W { int[2] a }, a class field Cell[3] cells)Built when the object or struct is created from 0.16.0, as a sized local is, with the field initializers. Up to 0.15.x (and in the v0.15.2 seed) the size was ignored: the field was an empty array and every subscript failed with index out of range.
A sized array of more than one dimension (int[2][3] g, Cell[2][2] grid)Built whole from 0.16.0: 2 rows of 3, the dimensions in the order of the subscripts, every row built as a sized array of one dimension is; an element that fails to build releases the rows already built. Up to 0.15.x (and in the v0.15.2 seed) only the outer array was built and its sizes were read in the opposite order: every subscript failed with index out of range.
Two generic functions with the same name in two namespaces (one.a.pick<T>, two.b.pick<T>), called with a namespace (a.pick(1), b.pick(1))Each call reaches its own from 0.16.0: a generic function is found like any other function, in the caller's scope for a bare name and in the named namespace for a qualified one; a generic the named namespace does not have is no function or method named … matches this call. Up to 0.15.x (and in the v0.15.2 seed) generic functions were found by name alone: both calls ran the same one, and a call could reach a generic of a namespace it did not name; neither was reported.
A call to a generic function whose other arguments do not fit the type its first argument gives T (pick(1, "hello") for T pick<T>(const T a, const T b)), passes a wrong type to a parameter that is not T, gives too many or too few arguments, or binds T through an array parameter (T last<T>(const T[] xs) called with an int[])Checked like any call from 0.16.0: T is bound by the first argument that gives it, through T or T[], then the count and every argument are checked against the specialized parameters; a mismatch is no function or method named … matches this call. Up to 0.15.x (and in the v0.15.2 seed) only the arguments that bound T were looked at: pick(1, "hello") compiled and read the string as an int, pick("a", 42) crashed at run time, a wrong argument count stopped the compiler in the backend, and T[] did not bind T (cannot instantiate generic).
Two specializations of one generic class (Box<int>, Box<string>)Released each as itself from 0.16.0. Up to 0.15.x (the v0.15.2 seed included) they shared the release helper of the first one built: the other was released with its fields, and with a field the release deleted the program could crash.
Order in which one scope releases its localsLast declared first from 0.16.0, on every exit (strings and arrays; objects go at the program's delete). Up to 0.15.x: declaration order.
An object deleted through a base class or interface referenceDefined from 0.16.0: destroyed as the class it was created with — that class's destructor and then its bases' run (or, with no destructor in the hierarchy, its free()). In 0.15.x only the fields of the reference's type were released: those of the subclass leaked, and a free() declared only by the subclass did not run.
An object created by a dynamic library (--lib-dyn) and deleted by the program that links itWorks from 0.16.0: both take the runtime from one shared library, fly_runtime (.dll, .so, .dylib), linked next to them; an object nobody deletes is in the report at the end of main. Up to 0.15.x each had its own copy of the runtime: on Windows the delete corrupted the heap (0xC0000374) and the library's objects were not reported; Linux worked because the loader bound both to one copy.
A number stored into a bool (bool b = 4, return n from a bool function, (bool)4)Becomes n != 0 from 0.16.0 (true for 4). Up to 0.15.x (the v0.15.2 seed included) it kept the lowest bit only: 4, 256 and (bool)4 were false, and a string or an object stored into a bool compiled.
A stringReleased automatically at scope exit and on reassignment. From 0.16.0 the same in a field, an array element and a struct member: a store copies it, an assignment frees the old buffer, the container frees it when it goes (delete, the array's last reference, the struct's scope). Up to 0.15.x only a local's was freed.
A structStack storage, released at scope exit, with the strings and arrays of its members (from 0.16.0). A copy (assignment, element, field, literal) duplicates them member by member. Up to 0.15.x a copy shared them with its source and none was freed.
delete of an object with string, array or struct fieldsReleases them from 0.16.0, after the destructor (the objects its fields refer to stay). Up to 0.15.x they were never released: 2,000,000 objects with one string field, created and deleted, reached 59 MB against 4 MB from 0.16.0.

Errors that are not handled

From 0.15.1 a failure cannot be ignored. When a called function fails, the caller stops right after the call and returns too, and so on up the stack, until a handle stops the error; an error that nobody handles ends the program from main, which prints it and exits with its code.

int load() {
    fail 7, "bad"
    return 1
}

void main() {
    int v = load()            // load failed: main stops here
    io.printLn("continued")   // NOT printed
}                             // the process exits with code 7
error 7: bad

To go on after a failure on purpose, put the call in handle { } and test error. Inside a handle the rest of the block is skipped too, from the failing call on.

Up to 0.15.0 the call returned, the caller continued with the next statement, and the value it received was the zero value of the return type: the program above printed continued before reporting error 7: bad.

The report names the failure that ended the program. From 0.16 a message built by an expression (fail 1, str.concat(what, ": x")) is reported, and a handle consumes the message along with the code; in 0.15.1 and 0.15.2 such a message was lost (error 1); and up to 0.15.2 a message consumed by an earlier handle reappeared in a later failure that had none of its own.

switch and fall-through

From 0.15.0 a case body never continues into the next label: the switch ends with the body. Several values share a body by being listed, case 1, 2:, and a case with no statements is a compile-time error. Up to 0.14.x a body that did not end in break continued into the next label, default included:

switch a {
    case 1: io.printLn("one")
    default: io.printLn("d")
}
// with a == 1: "one" from 0.15.0; "one" and then "d" up to 0.14.x

From 0.16.0 the subject and the labels are checked when the program is compiled. The subject is an integer, a bool or an enum value; each label is a constant of that type that fits it, and no value is a label twice. Each fault is an error at the label (a repeated one with a note at the first):

ProgramFrom 0.16.0Up to 0.15.x (the v0.15.2 seed included)
case 1: twice, case 3: then case 1, 3:, case E.A: twicethe case label 1 appears twice in this switchstopped in the LLVM verifier (Duplicate integer as switch case)
case k: with a variable ka case label must be a constantstopped in the LLVM verifier
switch s with a string or double sa switch selects on an integer, 'bool' or enum value, not on a 'string'stopped in the LLVM verifier
case 300: over a byte, case 4294967299: over an int, case -1: over a uintthe case label 300 does not fit 'byte', the type of the switch valuethe label was cut to the type: a byte 44 took case 300:
case Color.RED: over an int, case 1: over a Color, a constant of another enuma case label of type 'Color' in a switch over 'int'compiled, comparing the enum's number

Operator precedence

Precedence differs from C in two places:

  • Bitwise (& | ^) and shift (<< >>) operators bind looser than comparisons: a & b == c means a & (b == c).
  • && and || share one level, with the bitwise and shift operators, and associate left to right.

From 0.15.0 both are diagnosed: two different operators of that level without parentheses (a || b && c), or a comparison as the operand of a bitwise or shift operator (flags & mask == 0), is a compile-time error. Up to 0.14.x neither was, and the expression silently took the Fly reading.

String literals

From 0.15.0 an ordinary string literal decodes escape sequences (\n, \t, \\, \xHH, \u{H…}; an unknown one is a compile-time error), and """…""" is a raw literal that keeps backslashes and newlines as written (Language Reference §2.3.4). Up to 0.14.x escapes were not translated: "\n" was the two characters \ and n.

Number literals

A number literal is decimal digits with an optional fraction and exponent (Language Reference §2.3.1); Fly has no hexadecimal, binary or suffixed literals. From 0.16.0 a literal that is not one, or whose value its type cannot hold, is a compile-time error naming it. Up to 0.15.x (the v0.15.2 seed included) the compiler read only the digits it understood (fly-lang/fly#332):

LiteralUp to 0.15.xFrom 0.16.0
0x10, 0b101, 12abc, 7L10, 101, 12, 7invalid number literal '0x10'
2.5.3, 1..2, 3.abc0.0invalid number literal '2.5.3'
99999999999999999999999, 18446744073709551616wrapped: 200376420520689663, 0number literal '…' does not fit 'ulong'
1e400infinitynumber literal '1e400' does not fit 'double'

The standard library had three such literals: the SplitMix64 constants that math.randSeed mixes the seed with were written in hexadecimal. From 0.16.0 they have their real values, so a given seed produces a different (the intended) stream than in 0.15.x.


The standard library

The library reports failure in several ways. Until it is unified on fail, read each function's description:

ConventionUsed by
Sentinel result (fd < 0, 0, "", empty buffer)fly.os.fs, fly.os.io, fly.net, fly.net.tls, fly.os.env
bool resultfly.net options, fly.net.http downloads, fly.targz extraction
int errOut parameterfly.codec, fly.json, fly.targz
Zero value of the element typefly.data containers, for a missing key or an out-of-range index
failfly.assert, and a few checks in fly.hash and fly.net

Consequences worth keeping in mind:

  • fs.read returns an empty buffer both for an empty file and for a missing one. Call fs.exists first when the difference matters.
  • List.get, Map.get and the pop/peek methods return 0, "" or null when there is nothing to return. Use size(), isEmpty() or has().
  • fly.data.Tree is an AVL tree from 0.16.0: O(log n) whatever order the keys arrive in. Up to 0.15.x it did not balance itself, and keys inserted in sorted order made every operation linear.
  • Map and Set hash with a key drawn at random once per process from 0.16.0, so their key order is unspecified and changes between runs. Up to 0.15.x strings were hashed with unseeded 32-bit FNV-1a and integers by their low 32 bits: keys chosen by an attacker, or spaced by a power of two, collided.
  • json.parse accepts 512 levels of nested arrays and objects; deeper is error 314 (json.parseDepth takes another limit). Up to 0.15.x it had no limit and a deeply nested document overflowed the stack.
  • fly.math random functions are a fast statistical generator (xoshiro256**), not a cryptographic one. The library has no CSPRNG.
  • fly.net addresses are IPv4 only.
  • fly.sync threads are detached; there is no join. Containers are not thread-safe.
  • fly.net.tls verifies certificates and host names by default; only tlsConnectOpts / tlsWrap with verify = false turn that off.
  • fly.targz rejects absolute paths and .. components when extracting.
  • fly.targz stops at 256 MiB of decompressed output with error 13 (inflateMax, gunzipMax, extractTarGzMax take another limit). Up to 0.15.x a small "zip bomb" could exhaust memory.

Platforms

TargetStatus
Linux x86_64built and tested in CI
Windows x64 (UCRT, no Visual Studio needed)built and tested in CI
macOSnot supported for now: runtime sources are in the tree, but nothing builds or tests them
aarch64not built

Protections of the programs

From 0.16.0 every program Fly links carries the protections of its system, at no cost once it runs (fly-lang/fly#320). A guard of the bootstrap (test_hardening) reads the headers of a built program and of the shipped tools and fails the build when one is missing.

ProtectionWindowsLinuxmacOS
Address randomization (ASLR) of the program itselfon, 64-bit range (high entropy)on from 0.16.0: the program is position independent (PIE); -static links it at a fixed address. Up to 0.15.x it was always at a fixed addresson (PIE)
Data and stack never executable (NX)ononon
Relocated data read-only after start-up (full RELRO)—on from 0.16.0 (up to 0.15.x partial)—
Hardware shadow stack (CET)compatible from 0.16.0: the CPU checks every return, where it cannot yet (fly-lang/fly#358)—
A frame larger than a page touches each page (stack-clash probes)on (__chkstk)on from 0.16.0on from 0.16.0
Control Flow Guardnot yet (fly-lang/fly#357): it checks every indirect call, so its cost is measured first——

No stack canaries. Arrays live on the heap and every subscript is checked, so a local buffer cannot overflow into the return address; the canaries would run in nearly every function (an output parameter takes a local's address) and protect little.


Reporting a difference

If the compiler accepts or rejects something in a way neither this page nor the Language Reference describes, that is a bug in one of the three. Please report it at https://github.com/fly-lang/fly/issues with the smallest program that shows it and the output of fly --version.