Skip to content

Core 0.4.0

Latest

Choose a tag to compare

@zweiler1 zweiler1 released this 09 Jul 18:32
781b316

TLDR

  • Added the flintc and fip-c packages in the AUR
  • Added the flintc and fip-c packages in the COPR repository
  • Added Flint.Flintc, Flint.Fls and Flint.Fip-C packages to Winget
  • Fixed Windows being entirely broken since v0.3.2
  • Added debug symbols etc to enable debugging of Flint programs using gdb. All Flint types have proper debug type representations, code stepping & breakpoints now work too, so Flint now can fully be debugged. lldb works too for debugging, but many types are incorrectly displayed in it (caused by it's incapability of evaluating debug expressions at debug-time, for whatever reason)
  • Added proper hover information to the LSP when hovering over variables and types, added ability to jump to definitions / declarations of variables, added ability to jump to imported files
  • Added ability to define named opaque types:
use Core.print

opaque NamedOpaque;

extern def create_named_opaque() -> NamedOpaque;
extern def free_named_opaque(mut NamedOpaque* value);

def main():
	print("Hello, World!\n");
	NamedOpaque o = create_named_opaque();
	print($"Created new named opaque {o}\n");
	free_named_opaque(&o);
#include <stdio.h>
#include <stdlib.h>

typedef void *NamedOpaque;

NamedOpaque create_named_opaque() {
    printf("Creating new named opaque\n");
    NamedOpaque no = (NamedOpaque)malloc(8);
    *(size_t *)no = (size_t)100;
    return no;
}

void free_named_opaque(NamedOpaque *value) {
    printf("Freeing named opaque %p\n", *value);
    free(*value);
    *value = NULL;
}
Hello, World!
Creating new named opaque
Created new named opaque 0x2f5440b0
Freeing named opaque 0x2f5440b0
  • Implemented "const array types", arrays with compile-time known sizes:
use Core.print

def main():
	i32[3] v3 = i32[3](0);
	v3.[0, 1, 2] = (10, 20, 30);
	for (i, elem) in v3:
		print($"v3[{i}] = {elem}\n");
v3[0] = 10
v3[1] = 20
v3[2] = 30
  • Added support for inline-initialized arrays:
  • Added ability to infer the sizes of inline-initialized arrays using the default operator / expression _:
use Core.print

def main():
	i32[] arr = i32[_]{10, 20, 30, 40};
	for (i, e) in arr:
		print($"arr[{i}] = {e}\n");
arr[0] = 10
arr[1] = 20
arr[2] = 30
arr[3] = 40
  • Added a lot of new error types for proper compile error printing. A lot of THROW_BASIC_ERR functions still need to be replaced with proper typed THROW_ERR calls, but we are slowly getting there...
  • Added ability to discard expression results using the default operator _:
use Core.print

def get_strings() -> (str, str):
	return ("Hi", "there");

def print_and_add(i32 x, i32 y) -> i32:
	print($"adding {x} and {y}\n");
	return x + y;

def main():
	(_, y) := get_strings();
	print($"y is \"{y}\"\n");

	_ = print_and_add(30, 40);
y is "there"
adding 30 and 40
  • Implemented ability to access data coming from parent entities within free-floating entity functions
use Core.print

data Data1:
	i32 x;
	i32 y;
	Data1(x, y);

data Data2:
	i32 z;
	i32 w;
	Data2(z, w);

func Func requires(Data1 d):
	def fun():
		print("fun\n");

entity E:
	data: Data1 d1;
	func: Func;
	E(d1)

entity Entity extends(E e1):
	data: Data2 d2;
	Entity(e1, d2);

	def print():
		print($"d1.(x, y) = {e1.d1.(x, y)}, d2.(z, w) = {d2.(z, w)}\n");

def main():
	e := Entity(Data1(10, 20), Data2(30, 40));
	e.print();
d1.(x, y) = (10, 20), d2.(z, w) = (30, 40)
  • Added ability to alias Core module imports (it was already working, but prevented by old explicit checks lol)
use Core.print as p

data Data1:
	i32 x;
	i32 y;
	Data1(x, y);

entity Entity:
	data: Data1 d1;
	Entity(d1);

	def print():
		p.print($"d1.(x, y) = {d1.(x, y)}\n");

def main():
	e := Entity(Data1(10, 20));
	e.print();
d1.(x, y) = (10, 20)

Changelog

  • Fixed Windows being entirely broken since v0.3.2 (Windows is a lot more sensible to these little mistakes than Linux is):
    • Fixed incorrect global variable name in time Core module on Windows (commit)
    • Fixed atomic store not working on optional wrapped pointer for the main function storage (commit)
    • Fixed DIMA head type duplication of types from Core modules (commit)
    • Fixed global eum string value cration duplication similar to recent DIMA head type duplication (commit)
    • Fixed a few incorrect signatures of C functions (commit)
    • Removed tail calling convention for Windows, it seems to dislike it pretty hard (commit)
    • Fixed enum value string deduplication code, had some logic errors (commit)
    • Fixed mistake where the SetConsoleOutputCP function to set console output to UTF-8 was never called in the test runner in Windows (commit)
    • Fixed bug in generate_visible_width_function where an i32 value was stored in the i64 allocation for the visible line width, leading in extremely large line widths -> garbage (commit)
    • Updated arrays wiki tests regarding CLI args to properly work on Windows (commit)
    • Fixed similar bug with potential garbage in generate_f64_to_str function like the previous generate_visible_width_function fix (commit)
    • Fixed uninitialized memory bug in generate_init_heads_function (commit)
    • Fixed 2_unwrap_err.ft test expecting the wrong exit code on Windows (commit)
    • Fixed off-by-one error in persistent frame freeing and cloning code (commit)
    • Fixed parse Core module not working on Windows because errno is not a global variable on Windows. You need to call _errno to get the value, you can't use the global variable directly (commit)
    • Fixed system Core module not working on Windows because stdout and stderr are not available as global variables. You need to call acrt_iob to get stdout / stderr on Windows (commit)
    • Fixed parse Core module through using strtoll / strtoull instead of strtol / strtoul for 64-bit integer parsing (commit)
    • Fixed AOC Day 2 on Windows (commit)
    • Fixed small logic bug in AOC day 4 which went unnoticed in Linux but leads to incorrect output on Windows (commit)
    • Fixed get_absolute function for absolute Windows paths (commit)
    • Added remove_with_retry function. This function is needed because removing the .obj file immediately after compiling crashes the compiler on Windows (invalid access exception) (commit)
  • Added a lot of new error types:
    • Added missing THROW_ERR calls for already present error types (commit)
    • Added the ErrDefFuncRequiredTypeNotData and ErrDefFuncRequiredTypeUnknown error types (commit)
    • Added the ErrDefEntityExtendedTypeNotEntity and ErrDefEntityExtendedTypeUnknown error types (commit)
    • Fixed incorrect types in constructors of newly added error types (commit)
    • Added ErrDefEntityNoData error type (commit)
    • Added the ErrFnDefMissing error type (commit)
    • Added ErrDefEntityDuplicateParent error type (commit)
    • Added ErrDefEntityDuplicateParentAccessor error type (commit)
    • Changed diagnostic output of ErrParsUnexpectedToken, it used a comma as a delimiter between tokens, but it looks very weird if one of the expected tokens is a comma too, it now uses spaces as token delimiters (commit)
    • Added ErrDefEntityDuplicateDataAccessor error type (commit)
    • Unified the ErrDefEntityDuplicateDataAccessor and ErrDefEnttiyDuplicateParentAccessor into a new ErrDefEntityDuplicateAccessor error type (commit)
    • Added ErrDefEntityMissingConstructor error type (commit)
    • Added ErrDefEntityProvidedTypeNotData error type (commit)
    • Fixed mistake where colors were used in the to_diagnostic function of the ErrDefEntityUnresolvedVirtual error type (commit)
    • Added ErrDefEntityProvidedTypeNotFunc error type (commit)
    • Added error handling instead of assertions in a few places (commit)
    • Added ErrDefEnttiyDuplicateAccessorInConstructor error type (commit)
    • Renamed entity constructor error types (commit)
    • Added ErrDefEntityConstructorNotData error type (commit)
    • Added ErrDefEntityConstructorDataWitoutAccessor error type (commit)
    • Added ErrDefEntityConstructorDataNotPresent error type (commit)
    • Added ErrDefEntityConstructorDuplicateData error type (commit)
    • Renamed ErrDefFunctionRedefinition to ErrFnRedefinition, fixed path printing of error (commit)
    • Added ErrDefEntityFnRedefinition error type (commit)
    • Added ErrDefEntityNoFunctionality error type (commit)
    • Renamed a few import-related error types to be more consistent, removed unused error types (commit)
    • Added cwd_relative inline helper function to the BaseError class (commit)
    • Added ErrImportDuplicateAlias error type (commit)
    • Changed BaseError::cwd_relative signature to correctly resolve hashes from Core modules too (commit)
    • Added ErrExprDataInitializerWrongArgCount error type (commit)
    • Added ErrExprDataInitializerMissingDefaultValue error type (commit)
    • Genralized the ErrExprDataInitializerWrongArgCount error type to the ErrExprInitializerWrongArgCount error type
    • Implemented proper error handling for type mismatches in entity initializers (commit)
    • Added ErrExprCastInvalid error type (commit)
    • Added ErrExprCastMultiLengthMismatch error type (commit)
    • Added ErrExprCallOnWrongInstanceType error type (commit)
    • Added ErrExprCallAmbiguous error type (commit)
    • Removed edge-case handling and THROW_BASIC_ERR cases in create_call_or_initializer_base function which were actually unreachable, changed them to assertions instead (commit)
    • Added ErrExprUnaryOpMissingExpr error type (commit)
    • Added ErrExprFieldNonexistent error type (commit)
    • Added ErrExprFieldAccessOnEntity error type (commit)
    • Added ErrExprFieldAccessNotAllowedOnType error type (commit)
    • Refactored the ErrExprFieldNonexistent error to preserve field ordering and properly added field-checking for multi-types (commit)
    • Added ErrExprEnumTagNotPresent error type (commit)
    • Implemented some error cases, removed some redundant THROW_BASIC_ERR calls (commit)
    • Added ErrExprArrayAccessNotAllowedOnType error type (commit)
    • Added ErrAnnotDuplicate error type (commit)
    • Added ErrAnnoUnknown error type (commit)
    • Added ErrAnnoLeftover error type (commit)
    • Added ErrEmptyStoredFixedArray error type (commit)
  • Implemented parsing of "const array types", array types whose sizes are compile-time known (commit)
  • Implemented codegen of arrays with comptime-known sizes (commit)
  • Added missing primitive types (u16, i8, i16) to FIP::convert_type function (commit)
  • Updated FIP, implemented the new FIP_TYPE_ARRAY capability (commit)
  • Moved all lambda "process functions" of the parse_all_open_XYZ functions to their own functions, it's just cleaner that way (commit)
  • Added checks for unexpected token and unexpected type error cases (commit)
  • Implemented ability to access data coming from parent entities within free-floating entity functions (commit)
  • Added ability to alias Core module imports (it was already working, but prevented by old explicit checks lol) (commit)
  • Removed unreachable code. Fip imports resolve to real file imports (commit)
  • Simplified unnecessarily complex code to get the function name since it's impossible for a function call to not have a name (it would not have been matched as a function call at all in this theorethical case) (commit)
  • Added get_signature_string function to FunctionNode, this reduces code duplication regarding the printing of functions by a lot (commit)
  • Added assert.hpp file which contains an ASSERT and UNREACHABLE macro (commit)
  • Removed all occurrences of assert, changed them to the new ASSERT macro which will be present in both debug and release builds (commit)
  • Removed all assert(false) calls, changed them to UNREACHABLE() instead (commit)
  • Added yaml files for winget, flintc and fls needed to be separate (commit)
  • Aded Nix and Fedora package files (.nix and .spec) (commit)
  • Added parse_program function to the parser to clean up the main file a bit (commit)
  • Removed the --print-fip-version flag since --version prints the FIP version already (commit)
  • Restructured and cleaned up main function, removed generate_program function from the file (commit)
  • Renamed CLP field build_exe to output_ll_file since that's more clear what it does, removed write_ll_file function (commit)
  • Moved compile_program function from main file to the generator where it belongs (commit)
  • Removed passing of the stack ptr as a register when in debug mode (commit)
  • Set codegen optlevel to none when in debug mode (commit)
  • Moved newline printing before the hard crash check, as the assertion would be printed in the same line as the file info otherwise (commit)
  • Added FIP version printing to the fls binary (commit)
  • Added the Generator::Debug subclass to provide debug symbols, debug types and the ability to debug Flint programs in general (commit)
  • Added ability to pass in the LLVM directory as a flag to the build script (for building with / for Nix) (commit)
  • Added ability to pass in the fip and json-mini dependency directories to the build script, alongside the git_hash and then git is no longer needed to build the compiler (for Nix builds) (commit)
  • Added "pos triple" to the initializer of expression nodes so that the fields line, column and length are always properly initialized for all expressions (commit)
  • Updated StatementNode initializers to make sure the file_hash, line, column and length fields of statements are always properly initialized (commit)
  • Added parameter to get_signature_string function of the FunctionNode to get get the function as a function reference when requested (commit)
  • Added file_hash, line and column fields to the scope variables to provide a way to "trace back" where a variable came from (commit)
  • Added the end_line field to the base ASTNode and set it when creating scoped statements or definitions (commit)
  • Added hover information and GOTO definition support to the FLS (commit)
  • Added ability to define named opaque types (commit)
  • Implemented named opaque types, updated FIP hash (commit)
  • Added support for inline-initialized arrays (commit)
  • Added ability to infer the sizes of inline-initialized arrays using default-expressions, fixed array_initializer pattern (commit)
  • Added missing newline to opaque help printing (commit)
  • Unified is_producer check directly as a new function in the ExpressionNode to reduce code-duplication and fragility (commit)
  • Added ability to discard expression results using the default operator _ (commit)
  • Refactored the utils.ft test runner to test compilation with different flags on all wiki tests. This helps to find bugs related to various compiler flags (bugs specific to the --parallel or -O fast flags for example) (commit)
  • Added emission of debug information for function parameters (commit)
  • Moved file_exists_and_is_readable and load_file functions from the Parser to the io.hpp file, created a new IO class to properly namespace the functions (commit)
  • Removed the -f / --file flags and moved to a position-independent file flag instead, added -T flag in addition to --target, changed --output-ll-file flag to --emit-ir (commit)
  • Removed --file flag requirements from all files and test files (commit)
  • Removed /usr/lib/libc.a file from possible_musl_paths, it prevented proper error messages to be printed when musl is not installed (commit)
  • Added compilation using the --static flag to the compile_v function of utils.ft (commit)
  • Changed overflow_mode and oob_mode fields to just mode instead, added optimize_mode field to the metadata.json to rebuild Core libraries when the optimize mode changes (commit)
  • Removed remains of the old "depth-1" LSP optimizations which now led to LSP crashes on larger multi-file projects (commit)
  • Added ability to use the reference operator & on arrays and added (missing) ability that any pointer type can be cast to any opaque type implicitely (commit)
  • Fixed bug where extending multiple entities would crash the compiler (commit)
  • Added wiki tests for named opaque types (commit)
  • Moved --no-fip flag from debug options to release options, now every version of the compiler has this flag (commit)
  • Cleaned up type analyzation, removed analyzation duplication from function definitions, statements and expressions. This also revealed a bug where the analyzer was actually run before parsing functions, which is wrong (commit)
  • Fixed bug where a dual EDG mapping would lead to an error, but this case is well-defined (commit)
  • Fixed incorrect parsing of entity constructors when extending multiple entities (commit)
  • Fixed bug where expressions like not true or not false would crash the parser (commit)
  • Fixed grouped enum values not working correctly, i missed that because assertions are disabled in release builds... (commit)
  • Fixed double-free bug for grouped data accesses (commit)
  • Fixed unnecessary allocation where scratchspace should have been used (commit)
  • Fixed bug where the wrong entity type was expected for initializer x if the initialization order and definition order of data of an entity differ (commit)
  • Fixed incorrect ll file outputting flag bug introduced in 0504f65 (commit)
  • Fixed mistake where the parser would hard-crash if an expression in a string interpolation is not castable to a string (commit)
  • Fixed mistake where base ASTNode fields were uninitialized for CatchNodes (commit)
  • Fixed mistake where base ASTNode fields were uninitialized for several statement nodes (commit)
  • Fixed bug in string interpolation creation where the length of the expression was garbage because the token at expr_tokens.end() was dereferenced and that token is uninitialized as it extends beyond the list. The lexer now properly inserts an EOF token for string interpolation content of size 1 (commit)
  • Fixed bug where transitive import optimization of the LSP led to incorrect error diagnostics (commit)
  • Fixed bug where the index and iterable in enhanced for loop and the iterable definition in the for loop were not collected in the get_all_variables function (commit)
  • Fixed bug where an llvm assertion was thrown because one DIBuilder can have atmost one DICompileUnit created from it (commit)
  • Fixed bug where else scope was a nullpointer because the if node was constructed before the end_line calculation (commit)
  • Fixed bug where debug allocations of enhanced for loops were tried to be accessed before they were created (commit)
  • Fixed bug where the compiler would crash because no DIFile exists for Core modules (commit)
  • Fixed bug where the expression being implicitely cast to an optional was not cast to the base cast first. This prevented i32[10] to be cast to i32[]? even though i32[10] is castable to i32[] (commit)
  • Fixed bug where recursive self-referential types (like data or callables) led to infinite recursion in the debug type creation (commit)
  • Fixed bug where opaque types were handled as references even though they are simple values passed around, like any other primitive value (commit)
  • Fixed #10, updated FIP version hash (commit)
  • Fixed functions and tests crashing when building in release mode as the DIBuilder is a nullptr in release mode (commit)
  • Fixed bug which led to variant extractions to be matched as array initializers (commit)
  • Fixed bug where all opaque types resolved to void* when resolving symbols in FIP instead of opaque types when they are named (commit)
  • Fixed bug where the null coalescing operator would return a reference to it's inner value instead of a clone of it leading to double-free errors (commit)
  • Fixed bug where string additions of string interpolations would lead to double-free errors because they would be marked as garbage twice (commit)
  • Fixed bug where compiling in release mode would crash the compiler because debug info tried to be emitted unconditionally (commit)
  • Fixed FIP not working with the --parallel thread since multiple threads tried to init FIP at once or send / recieve messages from the IMs. The FIP is inherently single-threaded (commit)
  • Fixed use-after free bug when returning a local variable from within a nested scope (commit)
  • Fixed bug where discarded calls would lead to the codegen phase crashing (commit)
  • Fixed entity dispatch function not working in release mode because of incorrect calling convention (missing tailcc on linux in release mode) (commit)
  • Fixed bug where concurrent line collapsing led to race condition when parsing all open entities in parallel (commit)
  • Fixed bug where a single data keyword without a following type group <...> was matched as a type, leading to crashes in the collapse type phase of entities (commit)
  • Fixed bug where the now resolved entity type was unexpected at the entity constructor line (it expected an initializer but now through the collapsing of the types it got a type) (commit)
  • Fixed bug where errno was not available in musl, which now means that the __errno_location function is called in both glibc and musl instead, similar to the _errno function on Windows (commit)
  • Fixed bug where sret allocations for extern calls were not generated in the Generator::Allocation::generate_call_allocations function (commit)
  • Fixed bug where wrong overload of llvm function to add parameter attributes was called leading to a thrown assertion (commit)
  • Fixed race condition where multiple threads mutated the per-instance last_parsed_call member of the parser, made the variable static but also thread_local to resolve this issue (commit)
  • Fixed bug where byval function attribute was not added to extern functions returning void (commit)
  • Fixed bug where captured entity identifiers were not passed down to child scopes in their creation (commit)
  • Fixed bug where the value and location pointers are swapped in an IR::aligned_store call in the generate_instance_call function leading to segmentation faults. Also the ordering was wrong, as the ts_ptr field is overwritten in the dispatch function in setup mode (commit)
  • Fixed bugs where putting a const in front of a def in entities or func modules did not properly change the mutability of the implicit parameters like it should have done (commit)
  • Fixed mistake where method calls were not allowed on const instances of func or entity types, but method calls are allowed on const instances if the called method is marked as const too (commit)
  • Fixed mistake where the types coming from aliased imported files could not be resolved in data and variant definitions (commit)
  • Fixed bug in resolve_alias_in_type function which consumed tokens but did not initialize the result.resolved_type in all code paths resulting in nullpointer crashes down the line elsewhere (commit)
  • Fixed bug where a call as the switcher expression would lead to the switch statement being interpreted as a call statement instead (commit)
  • Fixed bug where break statements only targetted the last loop blocks and not any switch blocks too, as you still can (and should be able to use) the break statement in switch branches too (for example to break out of the branch early) (commit)

Full Changelog: v0.3.5-core...v0.4.0-core