0.6.0: init_new/init_temp removed. LinkedList API rewritten. List "pop" and "remove" function now return Optionals. RingBuffer API rewritten. Allocator interface changed. Deprecated Allocator, DString and mem functions removed. "identity" functions are now constants for Matrix and Complex numbers. @default implementations for interfaces removed. any* => any, same for interfaces. Emit local/private globals as "private" in LLVM, following C "static". Updated enum syntax. Add support [rgba] properties in vectors. Improved checks of aliased "void". Subarray -> slice. Fix of llvm codegen enum check. Improved alignment handling. Add --output-dir #1155. Removed List/Object append. GenericList renamed AnyList. Remove unused "unwrap". Fixes to cond. Optimize output in dead branches. Better checking of operator methods. Disallow any from implementing dynamic methods. Check for operator mismatch. Remove unnecessary bitfield. Remove numbering in --list* commands Old style enum declaration for params/type, but now the type is optional. Add note on #1086. Allow making distinct types out of "void", "typeid", "anyfault" and faults. Remove system linker build options. "Try" expressions must be simple expressions. Add optimized build to Mac tests. Register int. assert(false) only allowed in unused branches or in tests. Compile time failed asserts is a compile time error. Remove current_block_is_target. Bug when assigning an optional from an optional. Remove unused emit_zstring. Simplify phi code. Remove unnecessary unreachable blocks and remove unnecessary current_block NULL assignments. Proper handling of '.' and Win32 '//server' paths. Add "no discard" to expression blocks with a return value. Detect "unsigned >= 0" as errors. Fix issue with distinct void as a member #1147. Improve callstack debug information #1184. Fix issue with absolute output-dir paths. Lambdas were not type checked thoroughly #1185. Fix compilation warning #1187. Request jump table using @jump for switches. Path normalization - fix possible null terminator out of bounds. Improved error messages on inlined macros.

Upgrade of mingw in CI. Fix problems using reflection on interface types #1203. Improved debug information on defer. $foreach doesn't create an implicit syntactic scope.
Error if `@if` depends on `@if`. Updated Linux stacktrace. Fix of default argument stacktrace. Allow linking libraries directly by file path. Improve inlining warning messages. Added `index_of_char_from`. Compiler crash using enum nameof from different module #1205. Removed unused fields in find_msvc. Use vswhere to find msvc. Update tests for LLVM 19
This commit is contained in:
Christoffer Lerno
2024-02-23 00:18:43 +01:00
parent 321c5ec756
commit e293c435af
271 changed files with 7608 additions and 6181 deletions

View File

@@ -18,7 +18,7 @@ Some short names:
| int | cond | sw/sn | always | explptr | no | expand | explbase | edist | no | no | no | no | no | edist | no |
| float | cond | expl | sw/sn | no | no | expand | no | edist | no | no | no | no | no | no | no |
| pointer | cond | explptr | no | ptrconv | arve | expand | no | edist | no | no | no | yes | expl | no | expl |
| subarray | cond | no | no | no | saconv | no | no | edist | no? | no | no | no | no | no | no |
| slice | cond | no | no | no | saconv | no | no | edist | no? | no | no | no | no | no | no |
| vec | cond | no | no | no | no | as base | no | edist | expl | no | no | no | no | no | no |
| bits | no | explbase | no | no | no | no | no? | edist | explbase | no | no | no | no | no | no |
| distc | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist |

View File

@@ -9,7 +9,7 @@ fault InterpretError
INTEPRET_FAILED
}
fn void! print_error(usz pos, String err)
fn void! print_error_type_at(usz pos, String err)
{
io::printfn("Error at %s: %s", pos, err);
return InterpretError.INTEPRET_FAILED?;
@@ -25,10 +25,10 @@ fn void! brainf(String program)
switch (c)
{
case '<':
if (!mem) return print_error(sp, "Memory underflow");
if (!mem) return print_error_type_at(sp, "Memory underflow");
mem--;
case '>':
if (mem == BF_MEM - 1) return print_error(sp, "Memory overflow");
if (mem == BF_MEM - 1) return print_error_type_at(sp, "Memory overflow");
mem++;
case '+':
memory[mem]++;
@@ -45,7 +45,7 @@ fn void! brainf(String program)
usz start = sp - 1;
while (indent)
{
if (sp == program.len) return print_error(start, "No matching ']'");
if (sp == program.len) return print_error_type_at(start, "No matching ']'");
switch (program[sp++])
{
case ']': indent--;
@@ -59,7 +59,7 @@ fn void! brainf(String program)
usz indent = 1;
while (indent)
{
if (!sp) return print_error(start, "No matching '['");
if (!sp) return print_error_type_at(start, "No matching '['");
switch (program[--sp])
{
case ']': indent++;

View File

@@ -27,7 +27,7 @@ struct Summary
bool ok;
}
fn void! Summary.print(Summary *s, OutStream* out)
fn void! Summary.print(Summary *s, OutStream out)
{
io::fprintf(out, "Summary({ .title = %s, .ok = %s})", s.title.get() ?? "missing", s.ok)!;
}
@@ -76,7 +76,7 @@ fn void main()
const String[] URLS = { "good", "title-empty", "title-missing", "head-missing", "fail" };
DynamicArenaAllocator dynamic_arena;
dynamic_arena.init(1024, allocator::heap());
OutStream* out = io::stdout();
OutStream out = io::stdout();
foreach (String url : URLS)
{
mem::@scoped(&dynamic_arena)

View File

@@ -1,7 +1,7 @@
module levenshtein;
import std::math;
// This levenshtein exercises C3 subarrays.
// This levenshtein exercises C3 slices.
fn int levenshtein(String s, String t)
{
// if either string is empty, difference is inserting all chars

View File

@@ -29,7 +29,7 @@
"link-libc": false,
"opt": "O0",
"safe": false,
"system-linker": true,
"linker": "builtin",
"use-stdlib": false,
},
},
@@ -68,8 +68,8 @@
// The size of the symtab, which limits the amount
// of symbols that can be used. Should usually not be changed.
"symtab": 1048576,
// Use the system linker.
"system-linker": false,
// Select linker.
"linker": "cc",
// Include the standard library.
"use-stdlib": true,
// Set general level of x64 cpu: "baseline", "ssse3", "sse4", "avx1", "avx2-v1", "avx2-v2", "avx512", "native".

View File

@@ -7,7 +7,7 @@ fn void! main()
String command = env::WIN32 ? "dir" : "ls";
SubProcess x = process::create({ command }, { .search_user_path = true })!!;
x.join()!;
InStream* stream = &&x.stdout();
InStream stream = &&x.stdout();
while (try char b = stream.read_byte())
{
io::printf("%c", b);

View File

@@ -66,7 +66,7 @@
// of symbols that can be used. Should usually not be changed.
"symtab": 1048576,
// Use the system linker.
"system-linker": false,
"linker": "cc",
// Include the standard library.
"use-stdlib": true,
// Set general level of x64 cpu: "baseline", "ssse3", "sse4", "avx1", "avx2-v1", "avx2-v2", "avx512", "native".

View File

@@ -0,0 +1,11 @@
fn void main() {
foo();
}
fn void foo() {
bar();
}
macro bar() {
unreachable();
}

View File

@@ -320,7 +320,12 @@ relational_stmt_expr
| relational_stmt_expr relational_op additive_expr
;
rel_or_lambda_expr
try_catch_rhs_expr
: call_expr
| lambda_decl IMPLIES relational_expr
;
try_chain_expr
: relational_expr
| lambda_decl IMPLIES relational_expr
;
@@ -484,7 +489,7 @@ enum_list
enum_constant
: CONST_IDENT opt_attributes
| CONST_IDENT '(' arg_list ')' opt_attributes
| CONST_IDENT opt_attributes '=' constant_expr
;
identifier_list
@@ -493,9 +498,7 @@ identifier_list
;
enum_param_decl
: type
| type IDENT
| type IDENT '=' expr
: type IDENT
;
base_type
@@ -638,15 +641,15 @@ catch_unwrap
;
try_unwrap
: TRY rel_or_lambda_expr
| TRY IDENT '=' rel_or_lambda_expr
| TRY type IDENT '=' rel_or_lambda_expr
: TRY try_catch_rhs_expr
| TRY IDENT '=' try_chain_expr
| TRY type IDENT '=' try_chain_expr
;
try_unwrap_chain
: try_unwrap
| try_unwrap_chain AND_OP try_unwrap
| try_unwrap_chain AND_OP rel_or_lambda_expr
| try_unwrap_chain AND_OP try_chain_expr
;
default_stmt
@@ -1017,12 +1020,6 @@ enum_params
| enum_params ',' enum_param_decl
;
enum_param_list
: '(' enum_params ')'
| '(' ')'
| empty
;
struct_member_decl
: type identifier_list opt_attributes ';'
| struct_or_union IDENT opt_attributes struct_body
@@ -1034,12 +1031,14 @@ struct_member_decl
;
enum_spec
: ':' type enum_param_list
| empty
: ':' base_type '(' enum_params ')'
| ':' base_type
| ':' '(' enum_params ')'
;
enum_declaration
: ENUM TYPE_IDENT opt_interface_impl enum_spec opt_attributes '{' enum_list '}'
| ENUM TYPE_IDENT opt_interface_impl opt_attributes '{' enum_list '}'
;
faults

View File

@@ -12,7 +12,26 @@ fn void test1()
{
(void)test2();
}
fn void foo()
{
baz();
}
macro bar()
{
builtin::print_backtrace("bar", 1);
}
macro baz()
{
bar();
}
fn void main()
{
test1();
foo();
}

View File

@@ -21,7 +21,7 @@ fn void setstring(char* dst, String str)
dst[0] = 0;
}
fn void testAllocator(Allocator* a, int val)
fn void testAllocator(Allocator a, int val)
{
io::printn("Test");
void* data = allocator::malloc_aligned(a, val, 128, 16)!!;

View File

@@ -111,7 +111,7 @@ fn void testArrays()
printArray(&x);
printArray(y);
printArray(x[1..]);
puts("Array to pointer to subarray---");
puts("Array to pointer to slice---");
int* z = &x;
printArray(z[0..2]);
printf("Pointer to array: %p\nPointer to slice: %p\nPointer to first element of slice: %p\n", z, &y, &y[0]);