diff --git a/lib/std/atomic_nolibc.c3 b/lib/std/atomic_nolibc.c3 index cdac3199e..5c0fde4ac 100644 --- a/lib/std/atomic_nolibc.c3 +++ b/lib/std/atomic_nolibc.c3 @@ -58,7 +58,7 @@ fn CInt __atomic_compare_exchange(CInt size, any ptr, any expected, any desired, nextcase; $endif default: - unreachable("Unsuported size (%d) for atomic_compare_exchange", size); + unreachable("Unsupported size (%d) for atomic_compare_exchange", size); } return 0; -} \ No newline at end of file +} diff --git a/lib/std/core/allocators/dynamic_arena.c3 b/lib/std/core/allocators/dynamic_arena.c3 index bb29a9631..5faf3f7a7 100644 --- a/lib/std/core/allocators/dynamic_arena.c3 +++ b/lib/std/core/allocators/dynamic_arena.c3 @@ -13,7 +13,7 @@ import std::math; The advantage over the BackedArenaAllocator, is that when allocating beyond the first "page", it will retain the characteristics of an arena allocator (allocating a large piece of memory then handing off - memory from that memory), wheras the BackedArenaAllocator will have heap allocator characteristics. + memory from that memory), whereas the BackedArenaAllocator will have heap allocator characteristics. *> struct DynamicArenaAllocator (Allocator) { diff --git a/lib/std/core/allocators/tracking_allocator.c3 b/lib/std/core/allocators/tracking_allocator.c3 index 3fe0cb77b..00ce4d90a 100644 --- a/lib/std/core/allocators/tracking_allocator.c3 +++ b/lib/std/core/allocators/tracking_allocator.c3 @@ -19,7 +19,7 @@ alias AllocMap = HashMap { uptr, Allocation }; // It tracks allocations using a hash map but // is not compatible with allocators that uses mark() // -// It is also embarassingly single-threaded, so +// It is also embarrassingly single-threaded, so // do not use it to track allocations that cross threads. struct TrackingAllocator (Allocator) @@ -216,4 +216,4 @@ fn void? TrackingAllocator.fprint_report(&self, OutStream out) => @pool() } } } -} \ No newline at end of file +} diff --git a/lib/std/core/array.c3 b/lib/std/core/array.c3 index fbd6cba0b..4412019bd 100644 --- a/lib/std/core/array.c3 +++ b/lib/std/core/array.c3 @@ -142,7 +142,7 @@ macro tconcat(arr1, arr2) @nodiscard => concat(tmem, arr1, arr2); @param [in] array @param identity - @param #operation : "The reduction/folding labmda function or function pointer to apply." + @param #operation : "The reduction/folding lambda function or function pointer to apply." @require @is_valid_list(array) : "Expected a valid list" @require $defined($typefrom(@reduce_fn(array, identity)) $func = #operation) : "Invalid lambda or function pointer type" @@ -554,4 +554,4 @@ macro bool @is_valid_fill(left, right, fill_with = ...) $endif } -macro usz find_len(list) => $defined(list.len()) ??? list.len() : list.len; \ No newline at end of file +macro usz find_len(list) => $defined(list.len()) ??? list.len() : list.len; diff --git a/lib/std/core/builtin.c3 b/lib/std/core/builtin.c3 index 473c034f6..553e47ab5 100644 --- a/lib/std/core/builtin.c3 +++ b/lib/std/core/builtin.c3 @@ -7,7 +7,7 @@ import libc, std::hash, std::io, std::os::backtrace; <* EMPTY_MACRO_SLOT is a value used for implementing optional arguments for macros in an efficient - way. It relies on the fact that distinct types are not implicitly convertable. + way. It relies on the fact that distinct types are not implicitly convertible. You can use `@is_empty_macro_slot()` and `@is_valid_macro_slot()` to figure out whether the argument has been used or not. diff --git a/lib/std/core/types.c3 b/lib/std/core/types.c3 index 4fa7d595e..797cfc37f 100644 --- a/lib/std/core/types.c3 +++ b/lib/std/core/types.c3 @@ -115,7 +115,9 @@ fn bool TypeKind.is_int(kind) @inline return kind == TypeKind.SIGNED_INT || kind == TypeKind.UNSIGNED_INT; } -macro bool is_slice_convertable($Type) +macro bool is_slice_convertable($Type) @deprecated("Use is_slice_convertible") => is_slice_convertible($Type); + +macro bool is_slice_convertible($Type) { $switch $Type.kindof: $case SLICE: diff --git a/lib/std/crypto/ed25519.c3 b/lib/std/crypto/ed25519.c3 index c4e9954b9..8af9093a5 100644 --- a/lib/std/crypto/ed25519.c3 +++ b/lib/std/crypto/ed25519.c3 @@ -365,7 +365,7 @@ fn void F25519Int.normalize(&s) { s.reduce_carry((*s)[^1] >> 7); - // Substract p + // Subtract p F25519Int sub @noinit; ushort c = 19; foreach (i, v : (*s)[:^1]) @@ -399,7 +399,7 @@ fn char eq(F25519Int* a, F25519Int* b) } <* - Constant-time conditonal selection. Result is undefined if condition is neither 0 nor 1. + Constant-time conditional selection. Result is undefined if condition is neither 0 nor 1. @param [&in] zero : "selected if condition is 0" @param [&in] one : "selected if condition is 1" @@ -441,7 +441,7 @@ fn F25519Int F25519Int.add(&s, F25519Int* n) @operator(+) macro F25519Int F25519Int.@sub(&s, F25519Int #n) @operator(-) => s.sub(@addr(#n)); <* - Substraction. + Subtraction. @param [&in] s @param [&in] n @@ -638,7 +638,7 @@ fn FBaseInt from_bytes(char[] bytes) } <* - Constant-time conditonal selection. Result is undefined if condition is neither 0 nor 1. + Constant-time conditional selection. Result is undefined if condition is neither 0 nor 1. @param [&in] zero : "selected if condition is 0" @param [&in] one : "selected if condition is 1" @@ -676,7 +676,7 @@ fn FBaseInt FBaseInt.add(&s, FBaseInt* n) @operator(+) } <* - Substraction if RHS is less than LHS else identity. + Subtraction if RHS is less than LHS else identity. @param [&in] s @param [&in] n diff --git a/lib/std/io/file_mmap.c3 b/lib/std/io/file_mmap.c3 index a50f346b0..630a4ebcc 100644 --- a/lib/std/io/file_mmap.c3 +++ b/lib/std/io/file_mmap.c3 @@ -20,7 +20,7 @@ fn char[] FileMmap.bytes(&self) } <* - Destroys the underlyng VirtualMemory object ie. calls munmap()" + Destroys the underlying VirtualMemory object ie. calls munmap()" *> fn void? FileMmap.destroy(&self) @maydiscard { diff --git a/lib/std/io/stream/bytebuffer.c3 b/lib/std/io/stream/bytebuffer.c3 index 3e086314d..8335e9eaa 100644 --- a/lib/std/io/stream/bytebuffer.c3 +++ b/lib/std/io/stream/bytebuffer.c3 @@ -13,7 +13,7 @@ struct ByteBuffer (InStream, OutStream) <* ByteBuffer provides a streamable read/write buffer. - max_read defines how many bytes might be kept before its internal buffer is shrinked. + max_read defines how many bytes might be kept before its internal buffer is shrunk. @require self.bytes.len == 0 : "Buffer already initialized." *> fn ByteBuffer* ByteBuffer.init(&self, Allocator allocator, usz max_read, usz initial_capacity = 16) @@ -145,4 +145,4 @@ macro ByteBuffer.shrink(&self) self.write_idx = 1 + readable; self.read_idx = 1; } -} \ No newline at end of file +} diff --git a/lib/std/libc/libc.c3 b/lib/std/libc/libc.c3 index 8ad3842e3..b4dfda6fc 100644 --- a/lib/std/libc/libc.c3 +++ b/lib/std/libc/libc.c3 @@ -438,7 +438,7 @@ alias TimeOffset @if(!env::WASI) = CLong ; const int TIME_UTC = 1; -// This is a best-effort aproximation, but the C standard does not enforce +// This is a best-effort approximation, but the C standard does not enforce // that this is a compile-time standard. const CLOCKS_PER_SEC @if(env::WIN32) = 1000; const CLOCKS_PER_SEC @if(!env::WIN32) = 1000000; diff --git a/lib/std/math/math.c3 b/lib/std/math/math.c3 index 8ce850169..a6350cea3 100644 --- a/lib/std/math/math.c3 +++ b/lib/std/math/math.c3 @@ -252,8 +252,8 @@ macro @ceil($input) @const => $$ceil($input); @return "lower if x < lower, upper if x > upper, otherwise return x." @require types::is_numerical($typeof(x)) : `The input must be a numerical value or numerical vector` - @require $defined(x = lower) : `The lower bound must be convertable to the value type.` - @require $defined(x = upper) : `The upper bound must be convertable to the value type.` + @require $defined(x = lower) : `The lower bound must be convertible to the value type.` + @require $defined(x = upper) : `The upper bound must be convertible to the value type.` *> macro clamp(x, lower, upper) => $$max(($typeof(x))lower, $$min(x, ($typeof(x))upper)); diff --git a/lib/std/net/os/darwin.c3 b/lib/std/net/os/darwin.c3 index 9b74fb24b..3ef758836 100644 --- a/lib/std/net/os/darwin.c3 +++ b/lib/std/net/os/darwin.c3 @@ -67,7 +67,7 @@ const int SO_WANTMORE = 0x4000; // Apple: Give hint when more data re const int SO_WANTOOBFLAG = 0x8000; // Apple: Want OOB in MSG_FLAG on receive const int SO_SNDBUF = 0x1001; // Send buffer size -const int SO_RCVBUF = 0x1002; // Recieve buffer size +const int SO_RCVBUF = 0x1002; // Receive buffer size const int SO_SNDLOWAT = 0x1003; // Send low-water mark const int SO_RCVLOWAT = 0x1004; // Receive low-water mark const int SO_SNDTIMEO = 0x1005; // Send timeout @@ -94,4 +94,4 @@ const CShort POLLATTRIB = 0x0400; // file attributes may have changed const CShort POLLNLINK = 0x0800; // (un)link/rename may have happened const CShort POLLWRITE = 0x1000; // file's contents may have changed -const CInt MSG_PEEK = 0x0002; \ No newline at end of file +const CInt MSG_PEEK = 0x0002; diff --git a/lib/std/os/subprocess.c3 b/lib/std/os/subprocess.c3 index 774aa7855..a9be419c3 100644 --- a/lib/std/os/subprocess.c3 +++ b/lib/std/os/subprocess.c3 @@ -35,7 +35,7 @@ bitstruct SubProcessOptions : int { // Combine stdout and stderr to the same file bool combined_stdout_stderr; - // Child process should inhert env variables of parent process + // Child process should inherit env variables of parent process bool inherit_environment; // Enable async reading of stdout/stderr before completion bool read_async; diff --git a/lib/std/os/win32/memoryapi.c3 b/lib/std/os/win32/memoryapi.c3 index 8e5f9db04..176498844 100644 --- a/lib/std/os/win32/memoryapi.c3 +++ b/lib/std/os/win32/memoryapi.c3 @@ -36,7 +36,7 @@ enum Win32_FreeType : const Win32_DWORD MEM_COALESCE_PLACEHOLDERS = 0x00000001, MEM_PRESERVE_PLACEHOLDER = 0x00000002, } -extern fn Win32_LPVOID virtualAlloc(Win32_LPVOID lpAddres, Win32_SIZE_T dwSize, Win32_AllocationType flAllocationType, Win32_Protect flProtect) @extern("VirtualAlloc"); +extern fn Win32_LPVOID virtualAlloc(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_AllocationType flAllocationType, Win32_Protect flProtect) @extern("VirtualAlloc"); extern fn Win32_PVOID virtualAlloc2(Win32_HANDLE process, Win32_PVOID baseAddress, Win32_SIZE_T size, Win32_AllocationType allocationType, Win32_ULONG pageProtection, Win32_MEM_EXTENDED_PARAMETER* extendedParameters, Win32_ULONG parameterCount) @extern("VirtualAlloc2"); extern fn Win32_BOOL virtualFree(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_FreeType dwFreeType) @extern("VirtualFree"); extern fn Win32_BOOL virtualProtect(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_Protect flNewProtect, Win32_Protect* lpflOldProtect) @extern("VirtualProtect"); diff --git a/lib/std/os/win32/types.c3 b/lib/std/os/win32/types.c3 index 0fc54df29..595385ee3 100644 --- a/lib/std/os/win32/types.c3 +++ b/lib/std/os/win32/types.c3 @@ -432,7 +432,7 @@ struct Win32_XMM_SAVE_AREA32 Win32_UCHAR tagWord; Win32_UCHAR reserved1; Win32_USHORT errorOpcode; - Win32_ULONG errrorOffset; + Win32_ULONG errorOffset; Win32_USHORT errorSelector; Win32_USHORT reserved2; Win32_ULONG dataOffset; diff --git a/lib/std/sort/quicksort.c3 b/lib/std/sort/quicksort.c3 index d12e16440..3e326481e 100644 --- a/lib/std/sort/quicksort.c3 +++ b/lib/std/sort/quicksort.c3 @@ -82,8 +82,8 @@ fn void qsort(Type list, isz low, isz high, CmpFn cmp, Context context) } <* -@require low <= k : "kth smalles element is smaller than lower bounds" -@require k <= high : "kth smalles element is larger than upper bounds" +@require low <= k : "kth smallest element is smaller than lower bounds" +@require k <= high : "kth smallest element is larger than upper bounds" *> fn ElementType? qselect(Type list, isz low, isz high, isz k, CmpFn cmp, Context context) { diff --git a/releasenotes.md b/releasenotes.md index 877ab6949..113088822 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -296,7 +296,7 @@ - Linker errors when shadowing @local with public function #2198 - Bug when offsetting pointers of large structs using ++ and --. - `x++` and `x--` works on pointer vectors #2222. -- `x += 1` and `x -= 1` works propertly on pointer vectors #2222. +- `x += 1` and `x -= 1` works properly on pointer vectors #2222. - Fixes to `x += { 1, 1 }` for enum and pointer vectors #2222. - Linking fails on operator method imported as `@public` #2224. - Lambda C-style vaargs were not properly rejected, leading to crash #2229. @@ -423,7 +423,7 @@ - Regression with invalid setup of the WASM temp allocator. - Correctly detect multiple overloads of the same type. - ABI bug on x64 Linux / MacOS when passing a union containing a struct of 3 floats. #2087 -- Bug with slice acces as inline struct member #2088. +- Bug with slice access as inline struct member #2088. - `@if` now does implicit conversion to bool like `$if`. #2086 - Fix broken enum inline -> bool conversions #2094. - `@if` was ignored on attrdef, regression 0.7 #2093. @@ -568,7 +568,7 @@ ### Changes / improvements - Contracts @require/@ensure are no longer treated as conditionals, but must be explicitly bool. - Add `win-debug` setting to be able to pick dwarf for output #1855. -- Error on switch case fallthough if there is more than one newline #1849. +- Error on switch case fallthrough if there is more than one newline #1849. - Added flags to `c3c project view` to filter displayed properties - Compile time array assignment #1806. - Allow `+++` to work on all types of arrays. @@ -595,7 +595,7 @@ - Fix issue with `@const` where the statement `$foo = 1;` was not considered constant. - Const strings and bytes were not properly converted to compile time bools. - Concatenating a const empty slice with another array caused a null pointer access. -- Fix `linux-crt` and `linux-crtbegin` not getting recognized as a project paramater +- Fix `linux-crt` and `linux-crtbegin` not getting recognized as a project parameter - Fix dues to crash when converting a const vector to another vector #1864. - Filter `$exec` output from `\r`, which otherwise would cause a compiler assert #1867. - Fixes to `"exec" use, including issue when compiling with MinGW. @@ -717,7 +717,7 @@ - Prohibit raw vaargs in regular functions with a function body. - Assert on certain slice to slice casts. #1768. - Fix vector float -> bool conversion. -- Fix `+a = 1` erronously being accepted. +- Fix `+a = 1` erroneously being accepted. - Fix not freeing a zero length String - Macros with trailing bodys aren't allowed as the single statement after a while loop with no body #1772. - Deref subscripts as needed for macro ref method arguments. #1789 @@ -1668,7 +1668,7 @@ - Allow any expression as default expression. - Allow using enums for indexing arrays. -- Added $convertable / $castable compile time functions. +- Added $convertible / $castable compile time functions. - Removed ´func´ deprecated keyword - Slicing a distinct type now returns the distinct type. - Renamed @autoimport -> @builtin @@ -1685,7 +1685,7 @@ - Add linker and linked dir arguments to build files. - Auto-import std::core. - LLVM 15 support. -- Beter native file handling for MSVC +- Better native file handling for MSVC - New import rules – recursive imports - Add lld linking for FreeBSD - User defined attributes. @Foo = @inline diff --git a/resources/grammar/grammar.y b/resources/grammar/grammar.y index c36677344..d4e488976 100644 --- a/resources/grammar/grammar.y +++ b/resources/grammar/grammar.y @@ -1132,12 +1132,12 @@ parameter | CT_IDENT ELLIPSIS ; -func_defintion_decl +func_definition_decl : FN func_header fn_parameter_list opt_attributes ';' ; func_definition - : func_defintion_decl + : func_definition_decl | FN func_header fn_parameter_list opt_attributes macro_func_body ; @@ -1226,8 +1226,8 @@ define_declaration ; interface_body - : func_defintion_decl - | interface_body func_defintion_decl + : func_definition_decl + | interface_body func_definition_decl ; interface_declaration diff --git a/resources/grammar/grammar_proposal.y b/resources/grammar/grammar_proposal.y index 9a5c73e90..25b694f36 100644 --- a/resources/grammar/grammar_proposal.y +++ b/resources/grammar/grammar_proposal.y @@ -1144,12 +1144,12 @@ parameter | CT_IDENT ELLIPSIS ; -func_defintion_decl +func_definition_decl : FN func_header fn_parameter_list opt_attributes ';' ; func_definition - : func_defintion_decl + : func_definition_decl | FN func_header fn_parameter_list opt_attributes macro_func_body ; @@ -1223,8 +1223,8 @@ define_declaration ; interface_body - : func_defintion_decl - | interface_body func_defintion_decl + : func_definition_decl + | interface_body func_definition_decl ; interface_declaration diff --git a/src/build/build_options.c b/src/build/build_options.c index 02314d09c..190b01a1d 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -249,7 +249,7 @@ static void project_view_usage() PRINTF("the results will be printed out like they are in the full view."); PRINTF("Otherwise the \"
: \" is left out."); PRINTF(""); - PRINTF("With flags on, each selected property will be seperated by an empty"); + PRINTF("With flags on, each selected property will be separated by an empty"); PRINTF("line, and properties with multiple values (like --authors) will have"); PRINTF("their values printed each on a new line."); PRINTF(""); @@ -1270,7 +1270,7 @@ static void parse_option(BuildOptions *options) name); } char *name_copy = strdup(name); - str_ellide_in_place(name_copy, 32); + str_elide_in_place(name_copy, 32); if (strchr(name, '/') != NULL || (PLATFORM_WINDOWS && strchr(name, '\\') != NULL)) { error_exit( diff --git a/src/build/libraries.c b/src/build/libraries.c index 469c2f0ce..d322ba283 100644 --- a/src/build/libraries.c +++ b/src/build/libraries.c @@ -103,7 +103,7 @@ static Library *add_library(JSONObject *json, const char *dir) if (!str_is_valid_lowercase_name(provides)) { char *res = strdup(provides); - str_ellide_in_place(res, 32); + str_elide_in_place(res, 32); error_exit("Invalid 'provides' module name in %s, was '%s', the name should only contain alphanumerical letters and '_'.", library->dir, res); } library->provides = provides; diff --git a/src/build/project.c b/src/build/project.c index d25b6e4c6..9bbfd92da 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -246,7 +246,7 @@ static void load_into_build_target(BuildParseContext context, JSONObject *json, if (!str_is_valid_lowercase_name(name)) { char *name_copy = strdup(name); - str_ellide_in_place(name_copy, 32); + str_elide_in_place(name_copy, 32); error_exit("Error reading %s: invalid library target name '%s' – it should only contain alphanumerical letters and '_'.", context.file, name_copy); } } diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 87fcb4be3..ce86c4d8a 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -413,7 +413,7 @@ void compiler_parse(void) compiler_parsing_time = bench_mark(); } -bool compiler_should_ouput_file(const char *file) +bool compiler_should_output_file(const char *file) { if (!vec_size(compiler.build.emit_only)) return true; FOREACH(const char *, f, compiler.build.emit_only) diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 674bcef76..6973aa5cc 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -2478,7 +2478,7 @@ File *source_file_text_load(const char *filename, char *content); File *compile_and_invoke(const char *file, const char *args, const char *stdin_data, size_t limit); void compiler_parse(void); -bool compiler_should_ouput_file(const char *file); +bool compiler_should_output_file(const char *file); void emit_json(void); void stable_init(STable *table, uint32_t initial_size); diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index 32337a3c8..ca31074e7 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -1070,7 +1070,7 @@ static inline void llvm_optimize(GenContext *c) const char *llvm_codegen(void *context) { GenContext *c = context; - if (!compiler_should_ouput_file(c->base_name)) return NULL; + if (!compiler_should_output_file(c->base_name)) return NULL; llvm_optimize(c); // Serialize the LLVM IR, if requested, also verify the IR in this case diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index d0641c2de..12cf43fd6 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -4551,7 +4551,7 @@ static void llvm_emit_binary_expr(GenContext *c, BEValue *be_value, Expr *expr) // Operation + assign if (binary_op > BINARYOP_ASSIGN) { - // Finde the base op. + // Find the base op. BinaryOp base_op = binaryop_assign_base_op(binary_op); ASSERT(base_op != BINARYOP_ERROR); diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index 103881140..b61dd1714 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -589,7 +589,7 @@ void llvm_emit_for_stmt(GenContext *c, Ast *ast) llvm_emit_br(c, cond_block); break; case LOOP_INFINITE: - // We might have an infite loop + // We might have an infinite loop if (!loop_start_block) { SourceSpan loc = ast->span; diff --git a/src/compiler/parse_expr.c b/src/compiler/parse_expr.c index 51888ddb8..8b0ed36f5 100644 --- a/src/compiler/parse_expr.c +++ b/src/compiler/parse_expr.c @@ -1179,7 +1179,7 @@ static Expr *parse_ct_defined(ParseContext *c, Expr *left, SourceSpan lhs_start /** * ct_sizeof ::= CT_SIZEOF '(' expr ')' * - * Note that this is tranformed to $typeof(expr).sizeof. + * Note that this is transformed to $typeof(expr).sizeof. */ static Expr *parse_ct_sizeof(ParseContext *c, Expr *left, SourceSpan lhs_start UNUSED) { @@ -1599,7 +1599,7 @@ EXIT: is_unsigned = false; if (i128_comp(i, INT128_MIN, type_u128) == CMP_GT) { - PRINT_ERROR_AT(expr_int, "The negated integer size would exeed an int128."); + PRINT_ERROR_AT(expr_int, "The negated integer size would exceed an int128."); return poisoned_expr; } if (negated) i = i128_neg(i); diff --git a/src/compiler/sema_asm.c b/src/compiler/sema_asm.c index ee21e7515..05e980b6c 100644 --- a/src/compiler/sema_asm.c +++ b/src/compiler/sema_asm.c @@ -82,7 +82,7 @@ static inline Decl *sema_resolve_external_symbol(SemaContext *context, Expr *exp } return decl; } -static inline bool sema_reg_int_suported_type(AsmArgType arg, Type *type) +static inline bool sema_reg_int_supported_type(AsmArgType arg, Type *type) { ASSERT(type_flatten(type) == type); unsigned bits = type_bit_size(type); @@ -104,7 +104,7 @@ INLINE bool sema_reg_is_valid_in_slot(AsmRegister *reg, AsmArgType arg_type) UNREACHABLE } -static inline bool sema_reg_float_suported_type(AsmArgType arg, Type *type) +static inline bool sema_reg_float_supported_type(AsmArgType arg, Type *type) { ASSERT(type_flatten(type) == type); if (!arg.float_bits) return false; @@ -415,7 +415,7 @@ static inline bool sema_check_asm_var(SemaContext *context, AsmInlineBlock *bloc SEMA_ERROR(expr, "An integer variable was not expected here."); return false; } - if (!sema_reg_int_suported_type(arg_type, type)) + if (!sema_reg_int_supported_type(arg_type, type)) { unsigned bits = arg_bits_max(arg_type.ireg_bits, 0); ASSERT(bits); @@ -437,7 +437,7 @@ static inline bool sema_check_asm_var(SemaContext *context, AsmInlineBlock *bloc SEMA_ERROR(expr, "A floating point variable was not expected here."); return false; } - if (!sema_reg_float_suported_type(arg_type, type)) + if (!sema_reg_float_supported_type(arg_type, type)) { SEMA_ERROR(expr, "%s is not supported in this position, convert it to a valid type.", type_quoted_error_string(decl->type)); @@ -500,7 +500,7 @@ static inline bool sema_check_asm_arg_value(SemaContext *context, AsmInlineBlock if (type_is_pointer_type(type)) type = type_uptr->canonical; if (type_is_integer(type)) { - if (!sema_reg_int_suported_type(arg_type, type)) + if (!sema_reg_int_supported_type(arg_type, type)) { SEMA_ERROR(expr, "%s is not valid for this slot.", type_quoted_error_string(inner->type)); return false; @@ -511,7 +511,7 @@ static inline bool sema_check_asm_arg_value(SemaContext *context, AsmInlineBlock } if (type_is_float(type)) { - if (!sema_reg_float_suported_type(arg_type, type)) + if (!sema_reg_float_supported_type(arg_type, type)) { SEMA_ERROR(expr, "%s is not valid for this slot.", type_quoted_error_string(inner->type)); return false; diff --git a/src/compiler/sema_builtins.c b/src/compiler/sema_builtins.c index f64104adc..88beba663 100644 --- a/src/compiler/sema_builtins.c +++ b/src/compiler/sema_builtins.c @@ -472,7 +472,7 @@ bool sema_expr_analyse_str_wide(SemaContext *context, Expr *expr, BuiltinFunctio data += increment - 1; if (!from_codepoint) { - RETURN_SEMA_ERROR(inner, "Unparseable codepoint in string."); + RETURN_SEMA_ERROR(inner, "Unparsable codepoint in string."); } if (type == type_ushort && from_codepoint & 0xFFFF0000) { diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 063fadba6..882d6698a 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -273,7 +273,7 @@ bool sema_error_failed_cast(SemaContext *context, Expr *expr, Type *from, Type * */ Type *type_infer_len_from_actual_type(Type *to_infer, Type *actual_type) { - // This may be called on types not inferrable, + // This may be called on types not inferable, // if so we assume the original type if (!type_len_is_inferred(to_infer)) return to_infer; diff --git a/src/compiler/sema_const.c b/src/compiler/sema_const.c index 3ed085605..3b1a3dfcb 100644 --- a/src/compiler/sema_const.c +++ b/src/compiler/sema_const.c @@ -297,7 +297,7 @@ static inline ConstInitializer *expr_const_initializer_from_expr(Expr *expr) * * 1. String/Bytes + ... => String/Bytes * 2. Vector/slice/array + Untyped list => Merged untyped list - * 3. Vector/slice/array + arraylike => vector/array iff canoncial match, otherwise Untyped list + * 3. Vector/slice/array + arraylike => vector/array iff canonical match, otherwise Untyped list * 4. Untyped list + Vector/array/slice => Merged untyped list * 5. Vector/array/slice + element => Vector/array/slice + 1 len iff canonical match, Untyped list otherwise * 6. Untyped list + element => Untyped list diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 4f1256a77..ae3b603c6 100755 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -541,7 +541,7 @@ static bool sema_analyse_struct_members(SemaContext *context, Decl *decl) AlignSize member_type_alignment; if (type_is_user_defined(member_type) && member_type->decl->resolve_status == RESOLVE_RUNNING) { - SEMA_ERROR(member, "Recursive defintion of %s.", type_quoted_error_string(member_type)); + SEMA_ERROR(member, "Recursive definition of %s.", type_quoted_error_string(member_type)); return decl_poison(decl); } if (!sema_set_abi_alignment(context, member->type, &member_type_alignment)) return decl_poison(decl); @@ -5151,10 +5151,10 @@ Decl *sema_analyse_parameterized_identifier(SemaContext *c, Path *decl_path, con AnalysisStage stage = c->unit->module->generic_module ? c->unit->module->stage : c->unit->module->stage - 1; - bool instatiation = false; + bool instantiation = false; if (!instantiated_module) { - instatiation = true; + instantiation = true; Path *path = CALLOCS(Path); path->module = path_string; path->span = module->name->span; @@ -5172,7 +5172,7 @@ Decl *sema_analyse_parameterized_identifier(SemaContext *c, Path *decl_path, con sema_error_at(c, span, "The generic module '%s' does not have '%s' for this parameterization.", module->name->module, name); return poisoned_decl; } - if (instatiation) + if (instantiation) { if (instantiated_module->contracts) { diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 21f10d3ee..17afbdaaa 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -9120,7 +9120,7 @@ static inline bool sema_expr_analyse_or_error(SemaContext *context, Expr *expr, EndJump active_scope_jump = context->active_scope.end_jump; - // First we analyse the "else" and try to implictly cast. + // First we analyse the "else" and try to implicitly cast. if (!sema_analyse_inferred_expr(context, infer_type, right, NULL)) return false; if (left->expr_kind == EXPR_OPTIONAL) @@ -11001,7 +11001,7 @@ static inline bool sema_expr_analyse_builtin(SemaContext *context, Expr *expr, b static inline bool sema_expr_analyse_compound_literal(SemaContext *context, Expr *expr, bool *no_match_ref) { TypeInfo *type_info = expr->expr_compound_literal.type_info; - // We allow infering the size of arrays. + // We allow inferring the size of arrays. if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_ALLOW_INFER)) return false; Type *type = type_info->type; if (type_is_optional(type)) diff --git a/src/compiler_tests/tests.c b/src/compiler_tests/tests.c index 9863ac6f9..0c9ef5433 100644 --- a/src/compiler_tests/tests.c +++ b/src/compiler_tests/tests.c @@ -19,146 +19,146 @@ void test_file(void) void test128() { printf("Begin i128 testing.\n"); - Int128 addres = i128_add(i128(0x123, 0x123), i128(0x222, 0x333)); - TEST_ASSERTF(addres.high == 0x345 && addres.low == 0x456, "i128 add failed with small numbers was %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_add(i128(0x123, UINT64_MAX), i128(0x222, 0x1)); - TEST_ASSERT(addres.high == 0x346 && addres.low == 0, "i128 add failed with simple overflow"); - addres = i128_add(i128(0x123, UINT64_MAX), i128(0x222, UINT64_MAX)); - TEST_ASSERT(addres.high == 0x346 && addres.low == UINT64_MAX - 1, "i128 add failed with simple overflow2"); - addres = i128_add(i128(UINT64_MAX, UINT64_MAX), i128(0x0, 0x1)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "i128 add failed with wrap"); - addres = i128_add(i128(UINT64_MAX, UINT64_MAX), i128(UINT64_MAX, UINT64_MAX)); - TEST_ASSERT(addres.high == UINT64_MAX && addres.low == UINT64_MAX - 1, "i128 add failed overflow with wrap"); + Int128 address = i128_add(i128(0x123, 0x123), i128(0x222, 0x333)); + TEST_ASSERTF(address.high == 0x345 && address.low == 0x456, "i128 add failed with small numbers was %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_add(i128(0x123, UINT64_MAX), i128(0x222, 0x1)); + TEST_ASSERT(address.high == 0x346 && address.low == 0, "i128 add failed with simple overflow"); + address = i128_add(i128(0x123, UINT64_MAX), i128(0x222, UINT64_MAX)); + TEST_ASSERT(address.high == 0x346 && address.low == UINT64_MAX - 1, "i128 add failed with simple overflow2"); + address = i128_add(i128(UINT64_MAX, UINT64_MAX), i128(0x0, 0x1)); + TEST_ASSERT(address.high == 0 && address.low == 0, "i128 add failed with wrap"); + address = i128_add(i128(UINT64_MAX, UINT64_MAX), i128(UINT64_MAX, UINT64_MAX)); + TEST_ASSERT(address.high == UINT64_MAX && address.low == UINT64_MAX - 1, "i128 add failed overflow with wrap"); printf("-- i128 Add - Ok.\n"); - addres = i128_sub(i128(0x345, 0x457), i128(0x222, 0x333)); - TEST_ASSERTF(addres.high == 0x123 && addres.low == 0x124, "i128 sub failed with small numbers was %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_sub(i128(0x346, 0), i128(0x222, 0x1)); - TEST_ASSERTF(addres.high == 0x123 && addres.low == UINT64_MAX, "i128 sub failed with simple overflow %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_sub(i128(0x346, UINT64_MAX - 1), i128(0x222, UINT64_MAX)); - TEST_ASSERT(addres.high == 0x123 && addres.low == UINT64_MAX, "i128 sub failed with simple overflow2"); - addres = i128_sub(i128(0, 0), i128(0x0, 0x1)); - TEST_ASSERTF(addres.high == UINT64_MAX && addres.low == UINT64_MAX, "i128 sub failed with wrap %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_sub(i128(UINT64_MAX, UINT64_MAX - 1), i128(UINT64_MAX, UINT64_MAX)); - TEST_ASSERT(addres.high == UINT64_MAX && addres.low == UINT64_MAX, "i128 sub failed overflow with wrap"); + address = i128_sub(i128(0x345, 0x457), i128(0x222, 0x333)); + TEST_ASSERTF(address.high == 0x123 && address.low == 0x124, "i128 sub failed with small numbers was %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_sub(i128(0x346, 0), i128(0x222, 0x1)); + TEST_ASSERTF(address.high == 0x123 && address.low == UINT64_MAX, "i128 sub failed with simple overflow %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_sub(i128(0x346, UINT64_MAX - 1), i128(0x222, UINT64_MAX)); + TEST_ASSERT(address.high == 0x123 && address.low == UINT64_MAX, "i128 sub failed with simple overflow2"); + address = i128_sub(i128(0, 0), i128(0x0, 0x1)); + TEST_ASSERTF(address.high == UINT64_MAX && address.low == UINT64_MAX, "i128 sub failed with wrap %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_sub(i128(UINT64_MAX, UINT64_MAX - 1), i128(UINT64_MAX, UINT64_MAX)); + TEST_ASSERT(address.high == UINT64_MAX && address.low == UINT64_MAX, "i128 sub failed overflow with wrap"); printf("-- i128 Sub - Ok.\n"); - addres = i128_and(i128(0x0, 0x0), i128(UINT64_MAX, UINT64_MAX)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "And failed"); - addres = i128_and(i128(0x123, 0x123456789abcdef1), i128(UINT64_MAX, UINT64_MAX)); - TEST_ASSERT(addres.high == 0x123 && addres.low == 0x123456789abcdef1, "And failed"); - addres = i128_and(i128(0xabcdef2233, 0x123456789A), i128(0x0F0F0F0F0F0F, 0xF0F0F0F0F0F0)); - TEST_ASSERT(addres.high == 0x0b0d0f0203 && addres.low == 0x1030507090, "And failed"); + address = i128_and(i128(0x0, 0x0), i128(UINT64_MAX, UINT64_MAX)); + TEST_ASSERT(address.high == 0 && address.low == 0, "And failed"); + address = i128_and(i128(0x123, 0x123456789abcdef1), i128(UINT64_MAX, UINT64_MAX)); + TEST_ASSERT(address.high == 0x123 && address.low == 0x123456789abcdef1, "And failed"); + address = i128_and(i128(0xabcdef2233, 0x123456789A), i128(0x0F0F0F0F0F0F, 0xF0F0F0F0F0F0)); + TEST_ASSERT(address.high == 0x0b0d0f0203 && address.low == 0x1030507090, "And failed"); printf("-- i128 And - Ok.\n"); - addres = i128_or(i128(0x0, 0x0), i128(UINT64_MAX, UINT64_MAX)); - TEST_ASSERT(addres.high == UINT64_MAX && addres.low == UINT64_MAX, "Or failed"); - addres = i128_or(i128(0x123, 0x123456789abcdef1), i128(0x123203, 0x0)); - TEST_ASSERT(addres.high == 0x123323 && addres.low == 0x123456789abcdef1, "Or failed"); - addres = i128_or(i128(0xabcdef2233, 0x123456789A), i128(0x0F0F0F0F0F0F, 0xF0F0F0F0F0F0F0)); - TEST_ASSERTF(addres.high == 0x0FAFCFEF2F3F && addres.low == 0xF0F0F2F4F6F8FA, "Or failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + address = i128_or(i128(0x0, 0x0), i128(UINT64_MAX, UINT64_MAX)); + TEST_ASSERT(address.high == UINT64_MAX && address.low == UINT64_MAX, "Or failed"); + address = i128_or(i128(0x123, 0x123456789abcdef1), i128(0x123203, 0x0)); + TEST_ASSERT(address.high == 0x123323 && address.low == 0x123456789abcdef1, "Or failed"); + address = i128_or(i128(0xabcdef2233, 0x123456789A), i128(0x0F0F0F0F0F0F, 0xF0F0F0F0F0F0F0)); + TEST_ASSERTF(address.high == 0x0FAFCFEF2F3F && address.low == 0xF0F0F2F4F6F8FA, "Or failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Or - Ok.\n"); - addres = i128_xor(i128(0x0, 0x0), i128(UINT64_MAX, UINT64_MAX)); - TEST_ASSERT(addres.high == UINT64_MAX && addres.low == UINT64_MAX, "Xor failed"); - addres = i128_xor(i128(0x123, 0x123456789abcdef1), i128(0x123223, 0x0)); - TEST_ASSERT(addres.high == 0x123300 && addres.low == 0x123456789abcdef1, "Xor failed"); - addres = i128_xor(i128(0xabcdef2233, 0x123456789A), i128(0x0F0F0F0F0F0F, 0xF0F0F0F0F0F0F0)); - TEST_ASSERTF(addres.high == 0x0FA4C2E02d3c && addres.low == 0xF0F0e2c4a6886A, "Xor failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + address = i128_xor(i128(0x0, 0x0), i128(UINT64_MAX, UINT64_MAX)); + TEST_ASSERT(address.high == UINT64_MAX && address.low == UINT64_MAX, "Xor failed"); + address = i128_xor(i128(0x123, 0x123456789abcdef1), i128(0x123223, 0x0)); + TEST_ASSERT(address.high == 0x123300 && address.low == 0x123456789abcdef1, "Xor failed"); + address = i128_xor(i128(0xabcdef2233, 0x123456789A), i128(0x0F0F0F0F0F0F, 0xF0F0F0F0F0F0F0)); + TEST_ASSERTF(address.high == 0x0FA4C2E02d3c && address.low == 0xF0F0e2c4a6886A, "Xor failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Xor - Ok.\n"); - addres = i128_neg(i128(0x0, 0x0)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "Neg failed"); - addres = i128_neg(i128(0x123, 0x123456789abcdef1)); - TEST_ASSERT(addres.high == ~((uint64_t)0x123) && addres.low == ~(uint64_t)0x123456789abcdef0, "Neg failed"); - addres = i128_neg(i128(0xabcdef2233, 0x123456789A)); - TEST_ASSERTF(addres.high == ~(uint64_t)0xabcdef2233 && addres.low == ~(uint64_t)0x1234567899, "Neg failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + address = i128_neg(i128(0x0, 0x0)); + TEST_ASSERT(address.high == 0 && address.low == 0, "Neg failed"); + address = i128_neg(i128(0x123, 0x123456789abcdef1)); + TEST_ASSERT(address.high == ~((uint64_t)0x123) && address.low == ~(uint64_t)0x123456789abcdef0, "Neg failed"); + address = i128_neg(i128(0xabcdef2233, 0x123456789A)); + TEST_ASSERTF(address.high == ~(uint64_t)0xabcdef2233 && address.low == ~(uint64_t)0x1234567899, "Neg failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Neg - Ok.\n"); - addres = i128_from_str("1123"); - TEST_ASSERT(addres.high == 0 && addres.low == 1123, "Init failed"); - addres = i128_from_str("10000000000000000000012344434232"); - TEST_ASSERT(addres.high == 0x7e37be2022 && addres.low == 0xc0914b295fc91e38, "Init failed"); + address = i128_from_str("1123"); + TEST_ASSERT(address.high == 0 && address.low == 1123, "Init failed"); + address = i128_from_str("10000000000000000000012344434232"); + TEST_ASSERT(address.high == 0x7e37be2022 && address.low == 0xc0914b295fc91e38, "Init failed"); - addres = i128_mult(i128(0x111, 0x222), i128(0, 2)); - TEST_ASSERTF(addres.high == 0x222 && addres.low == 0x444, "Mult failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_mult(i128(0x111, 0x222), i128(2, 0)); - TEST_ASSERTF(addres.high == 0x444 && addres.low == 0, "Mult failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_mult(i128_from_str("523871293871232000123"), i128_from_str("283712312938293299")); + address = i128_mult(i128(0x111, 0x222), i128(0, 2)); + TEST_ASSERTF(address.high == 0x222 && address.low == 0x444, "Mult failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_mult(i128(0x111, 0x222), i128(2, 0)); + TEST_ASSERTF(address.high == 0x444 && address.low == 0, "Mult failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_mult(i128_from_str("523871293871232000123"), i128_from_str("283712312938293299")); - TEST_ASSERTF(i128_ucomp(i128_from_str("148628736466183585621117368965778075777"), addres) == CMP_EQ, "Mult failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + TEST_ASSERTF(i128_ucomp(i128_from_str("148628736466183585621117368965778075777"), address) == CMP_EQ, "Mult failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Mult ok.\n"); - TEST_ASSERTF(i128_ucomp(i128_from_str("123"), i128_from_str("123")) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128_from_str("123"), i128_from_str("124")) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128_from_str("123"), i128_from_str("121")) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128(0x222, 0x111), i128(0x111, 0x222)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128(0x111, 0x222), i128(0x222, 0x111)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128(0x222, 0x111), i128(0x222, 0x111)) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128(UINT64_MAX, 0x111), i128(0x111, 0x222)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_ucomp(i128(0x111, 0x222), i128(UINT64_MAX, 0x111)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + TEST_ASSERTF(i128_ucomp(i128_from_str("123"), i128_from_str("123")) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128_from_str("123"), i128_from_str("124")) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128_from_str("123"), i128_from_str("121")) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128(0x222, 0x111), i128(0x111, 0x222)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128(0x111, 0x222), i128(0x222, 0x111)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128(0x222, 0x111), i128(0x222, 0x111)) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128(UINT64_MAX, 0x111), i128(0x111, 0x222)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_ucomp(i128(0x111, 0x222), i128(UINT64_MAX, 0x111)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Ucomp ok.\n"); - TEST_ASSERTF(i128_scomp(i128_from_str("123"), i128_from_str("123")) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128_from_str("123"), i128_from_str("124")) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128_from_str("123"), i128_from_str("121")) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128(0x222, 0x111), i128(0x111, 0x222)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128(0x111, 0x222), i128(0x222, 0x111)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128(0x222, 0x111), i128(0x222, 0x111)) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128(UINT64_MAX, 0x111), i128(0x111, 0x222)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - TEST_ASSERTF(i128_scomp(i128(0x111, 0x222), i128(UINT64_MAX, 0x111)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + TEST_ASSERTF(i128_scomp(i128_from_str("123"), i128_from_str("123")) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128_from_str("123"), i128_from_str("124")) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128_from_str("123"), i128_from_str("121")) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128(0x222, 0x111), i128(0x111, 0x222)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128(0x111, 0x222), i128(0x222, 0x111)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128(0x222, 0x111), i128(0x222, 0x111)) == CMP_EQ, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128(UINT64_MAX, 0x111), i128(0x111, 0x222)) == CMP_LT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + TEST_ASSERTF(i128_scomp(i128(0x111, 0x222), i128(UINT64_MAX, 0x111)) == CMP_GT, "Comp failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Scomp ok.\n"); - addres = i128_shl(i128(0x234, 0x123456), i128(0, 0x4)); - TEST_ASSERT(addres.high == 0x2340 && addres.low == 0x1234560, "shl failed"); - addres = i128_shl(i128(0x234, 0x1234561), i128(0, 128)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "shl failed"); - addres = i128_shl(i128(0x234, 0x1234561), i128(1, 1)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "shl failed"); - addres = i128_shl(i128(0x234, 0x1234561), i128(0, 64)); - TEST_ASSERT(addres.high == 0x1234561 && addres.low == 0, "shl failed"); + address = i128_shl(i128(0x234, 0x123456), i128(0, 0x4)); + TEST_ASSERT(address.high == 0x2340 && address.low == 0x1234560, "shl failed"); + address = i128_shl(i128(0x234, 0x1234561), i128(0, 128)); + TEST_ASSERT(address.high == 0 && address.low == 0, "shl failed"); + address = i128_shl(i128(0x234, 0x1234561), i128(1, 1)); + TEST_ASSERT(address.high == 0 && address.low == 0, "shl failed"); + address = i128_shl(i128(0x234, 0x1234561), i128(0, 64)); + TEST_ASSERT(address.high == 0x1234561 && address.low == 0, "shl failed"); printf("-- i128 Shl ok.\n"); - addres = i128_lshr(i128(0x234, 0x123456), i128(0, 0x4)); - TEST_ASSERTF(addres.high == 0x23 && addres.low == 0x4000000000012345, "lshr failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_lshr(i128(0x234, 0x1234561), i128(0, 128)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "lshr failed"); - addres = i128_lshr(i128(0x234, 0x1234561), i128(1, 1)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "lshr failed"); - addres = i128_lshr(i128(0x234, 0x1234561), i128(0, 64)); - TEST_ASSERTF(addres.high == 0 && addres.low == 0x234, "lshr failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + address = i128_lshr(i128(0x234, 0x123456), i128(0, 0x4)); + TEST_ASSERTF(address.high == 0x23 && address.low == 0x4000000000012345, "lshr failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_lshr(i128(0x234, 0x1234561), i128(0, 128)); + TEST_ASSERT(address.high == 0 && address.low == 0, "lshr failed"); + address = i128_lshr(i128(0x234, 0x1234561), i128(1, 1)); + TEST_ASSERT(address.high == 0 && address.low == 0, "lshr failed"); + address = i128_lshr(i128(0x234, 0x1234561), i128(0, 64)); + TEST_ASSERTF(address.high == 0 && address.low == 0x234, "lshr failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Lshr ok.\n"); - addres = i128_ashr(i128(0x234, 0x123456), i128(0, 0x4)); - TEST_ASSERTF(addres.high == 0x23 && addres.low == 0x4000000000012345, "ashr failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_ashr(i128(0xF000000000000234, 0x123456), i128(0, 0x4)); - TEST_ASSERTF(addres.high == 0xFF00000000000023 && addres.low == 0x4000000000012345, "ashr failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_ashr(i128(0x234, 0x1234561), i128(0, 128)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "ashr failed"); - addres = i128_ashr(i128(0xF000000000000234, 0x1234561), i128(0, 128)); - TEST_ASSERT(addres.high == UINT64_MAX && addres.low == UINT64_MAX, "ashr failed"); - addres = i128_ashr(i128(0x234, 0x1234561), i128(1, 1)); - TEST_ASSERT(addres.high == 0 && addres.low == 0, "ashr failed"); - addres = i128_ashr(i128(0xF000000000000234, 0x1234561), i128(1, 1)); - TEST_ASSERT(addres.high == UINT64_MAX && addres.low == UINT64_MAX, "ashr failed"); - addres = i128_ashr(i128(0x234, 0x1234561), i128(0, 64)); - TEST_ASSERTF(addres.high == 0 && addres.low == 0x234, "ashr failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); - addres = i128_ashr(i128(0xF000000000000234, 0x1234561), i128(0, 64)); - TEST_ASSERTF(addres.high == UINT64_MAX && addres.low == 0xF000000000000234, "ashr failed %llx, %llx", (unsigned long long)addres.high, (unsigned long long)addres.low); + address = i128_ashr(i128(0x234, 0x123456), i128(0, 0x4)); + TEST_ASSERTF(address.high == 0x23 && address.low == 0x4000000000012345, "ashr failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_ashr(i128(0xF000000000000234, 0x123456), i128(0, 0x4)); + TEST_ASSERTF(address.high == 0xFF00000000000023 && address.low == 0x4000000000012345, "ashr failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_ashr(i128(0x234, 0x1234561), i128(0, 128)); + TEST_ASSERT(address.high == 0 && address.low == 0, "ashr failed"); + address = i128_ashr(i128(0xF000000000000234, 0x1234561), i128(0, 128)); + TEST_ASSERT(address.high == UINT64_MAX && address.low == UINT64_MAX, "ashr failed"); + address = i128_ashr(i128(0x234, 0x1234561), i128(1, 1)); + TEST_ASSERT(address.high == 0 && address.low == 0, "ashr failed"); + address = i128_ashr(i128(0xF000000000000234, 0x1234561), i128(1, 1)); + TEST_ASSERT(address.high == UINT64_MAX && address.low == UINT64_MAX, "ashr failed"); + address = i128_ashr(i128(0x234, 0x1234561), i128(0, 64)); + TEST_ASSERTF(address.high == 0 && address.low == 0x234, "ashr failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); + address = i128_ashr(i128(0xF000000000000234, 0x1234561), i128(0, 64)); + TEST_ASSERTF(address.high == UINT64_MAX && address.low == 0xF000000000000234, "ashr failed %llx, %llx", (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Ashr ok.\n"); TEST_ASSERT(i128_ucomp(i128_udiv(i128_from_str("123"), i128_from_str("123")), i128_from_str("1")) == CMP_EQ, "Div failed"); TEST_ASSERT(i128_ucomp(i128_udiv(i128_from_str("123"), i128_from_str("124")), i128_from_str("0")) == CMP_EQ, "Div failed"); TEST_ASSERT(i128_ucomp(i128_udiv(i128_from_str("245"), i128_from_str("123")), i128_from_str("1")) == CMP_EQ, "Div failed"); - addres = i128_udiv(i128(0x12345, UINT64_MAX), i128(1, 0)); - TEST_ASSERT(addres.low == 0x12345 && addres.high == 0, "Div failed"); - addres = i128_sdiv(i128(0x12345, UINT64_MAX), i128(1, 0)); - TEST_ASSERT(addres.low == 0x12345 && addres.high == 0, "Div failed"); - addres = i128_udiv(i128(UINT64_MAX, 0), i128(1, 0)); - TEST_ASSERT(addres.low == UINT64_MAX && addres.high == 0, "Div failed"); - addres = i128_sdiv(i128(UINT64_MAX - 1, UINT64_MAX - 1), i128(1, 0)); - TEST_ASSERTF(addres.low == UINT64_MAX && addres.high == UINT64_MAX, "Div failed %s", i128_to_string(addres, 10, + address = i128_udiv(i128(0x12345, UINT64_MAX), i128(1, 0)); + TEST_ASSERT(address.low == 0x12345 && address.high == 0, "Div failed"); + address = i128_sdiv(i128(0x12345, UINT64_MAX), i128(1, 0)); + TEST_ASSERT(address.low == 0x12345 && address.high == 0, "Div failed"); + address = i128_udiv(i128(UINT64_MAX, 0), i128(1, 0)); + TEST_ASSERT(address.low == UINT64_MAX && address.high == 0, "Div failed"); + address = i128_sdiv(i128(UINT64_MAX - 1, UINT64_MAX - 1), i128(1, 0)); + TEST_ASSERTF(address.low == UINT64_MAX && address.high == UINT64_MAX, "Div failed %s", i128_to_string(address, 10, true, false)); - addres = i128_sdiv(i128(2, 0), i128(UINT64_MAX - 1, UINT64_MAX - 1)); + address = i128_sdiv(i128(2, 0), i128(UINT64_MAX - 1, UINT64_MAX - 1)); printf("-- i128 Div okfefe %x.\n", (unsigned)-2); - TEST_ASSERTF(addres.low == UINT64_MAX && addres.high == UINT64_MAX, "Div failed: %s %llx, %llx", i128_to_string( - addres, 10, true, false), (unsigned long long)addres.high, (unsigned long long)addres.low); + TEST_ASSERTF(address.low == UINT64_MAX && address.high == UINT64_MAX, "Div failed: %s %llx, %llx", i128_to_string( + address, 10, true, false), (unsigned long long)address.high, (unsigned long long)address.low); printf("-- i128 Div ok.\n"); diff --git a/src/utils/lib.h b/src/utils/lib.h index 5d150067b..42eab7569 100644 --- a/src/utils/lib.h +++ b/src/utils/lib.h @@ -147,7 +147,7 @@ int str_findlist(const char *value, unsigned count, const char** elements); // Sprintf style, saved to an arena allocated string char *str_printf(const char *var, ...) __printflike(1, 2); char *str_vprintf(const char *var, va_list list); -void str_ellide_in_place(char *string, size_t max_size_shown); +void str_elide_in_place(char *string, size_t max_size_shown); bool str_is_valid_lowercase_name(const char *string); bool str_is_valid_constant(const char *string); const char *str_unescape(char *string); diff --git a/src/utils/stringutils.c b/src/utils/stringutils.c index ec39c0a82..1a6d65e47 100644 --- a/src/utils/stringutils.c +++ b/src/utils/stringutils.c @@ -168,7 +168,7 @@ bool str_is_valid_constant(const char *string) return true; } -void str_ellide_in_place(char *string, size_t max_size_shown) +void str_elide_in_place(char *string, size_t max_size_shown) { size_t len = strlen(string); if (max_size_shown > len) return; diff --git a/test/src/test_suite_runner.c3 b/test/src/test_suite_runner.c3 index 73098da91..5fe827a04 100644 --- a/test/src/test_suite_runner.c3 +++ b/test/src/test_suite_runner.c3 @@ -24,7 +24,7 @@ fn int main(String[] args) // Retain our current path. start_cwd = path::tcwd()!!; - // Create our test path, note that this prevents us from doing tests in parallell + // Create our test path, note that this prevents us from doing tests in parallel test_dir = start_cwd.tappend("_c3test_")!!; defer (void)path::rmtree(test_dir); diff --git a/test/test_suite/cast/cast_string_to_infered_array.c3 b/test/test_suite/cast/cast_string_to_inferred_array.c3 similarity index 100% rename from test/test_suite/cast/cast_string_to_infered_array.c3 rename to test/test_suite/cast/cast_string_to_inferred_array.c3 diff --git a/test/test_suite/expressions/check_implict_conversion_signed_unsigned.c3t b/test/test_suite/expressions/check_implicit_conversion_signed_unsigned.c3t similarity index 100% rename from test/test_suite/expressions/check_implict_conversion_signed_unsigned.c3t rename to test/test_suite/expressions/check_implicit_conversion_signed_unsigned.c3t diff --git a/test/test_suite/functions/defered_default_arguments.c3t b/test/test_suite/functions/deferred_default_arguments.c3t similarity index 100% rename from test/test_suite/functions/defered_default_arguments.c3t rename to test/test_suite/functions/deferred_default_arguments.c3t diff --git a/test/test_suite/statements/fallthough_do.c3t b/test/test_suite/statements/fallthrough_do.c3t similarity index 100% rename from test/test_suite/statements/fallthough_do.c3t rename to test/test_suite/statements/fallthrough_do.c3t diff --git a/test/test_suite/struct/member_expr.c3 b/test/test_suite/struct/member_expr.c3 index fc0cbbb8d..fac6c326e 100644 --- a/test/test_suite/struct/member_expr.c3 +++ b/test/test_suite/struct/member_expr.c3 @@ -20,12 +20,12 @@ fn void test_unknown_member() } -fn void test_nonstatic_stuct_func1() +fn void test_nonstatic_struct_func1() { Func2 a = &Foo.func2; } -fn void test_nonstatic_stuct_func2() +fn void test_nonstatic_struct_func2() { int b = Foo.func2(null, 2); } diff --git a/test/test_suite/struct/struct_recursive.c3 b/test/test_suite/struct/struct_recursive.c3 index 3e45e317c..ebbfb76c4 100644 --- a/test/test_suite/struct/struct_recursive.c3 +++ b/test/test_suite/struct/struct_recursive.c3 @@ -5,5 +5,5 @@ struct GlobalNode struct Ast { - GlobalNode global; // #error: Recursive defintion of 'GlobalNode' -} \ No newline at end of file + GlobalNode global; // #error: Recursive definition of 'GlobalNode' +} diff --git a/test/test_suite/switch/switch_in_defer_macro.c3t b/test/test_suite/switch/switch_in_defer_macro.c3t index 5f2433cb2..007b66ca0 100644 --- a/test/test_suite/switch/switch_in_defer_macro.c3t +++ b/test/test_suite/switch/switch_in_defer_macro.c3t @@ -409,7 +409,7 @@ alias Kind = Kind{Token, Comment}; enum Token : char (String token) { - KEYWORD1 = "keword1", + KEYWORD1 = "keyword1", KEYWORD2 = "keyword2", SINGLE = "//", MULTI = "/*", @@ -686,11 +686,11 @@ fn void test() @.enum.MULTI = internal constant [6 x i8] c"MULTI\00", align 1 @"$ct.char" = linkonce global %.introspect { i8 3, i64 0, ptr null, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 @"$ct.lexer_test.Token" = linkonce global { i8, i64, ptr, i64, i64, i64, [4 x %"char[]"] } { i8 8, i64 0, ptr null, i64 1, i64 ptrtoint (ptr @"$ct.char" to i64), i64 4, [4 x %"char[]"] [%"char[]" { ptr @.enum.KEYWORD1, i64 8 }, %"char[]" { ptr @.enum.KEYWORD2, i64 8 }, %"char[]" { ptr @.enum.SINGLE, i64 6 }, %"char[]" { ptr @.enum.MULTI, i64 5 }] }, align 8 -@.str = private unnamed_addr constant [8 x i8] c"keword1\00", align 1 +@.str = private unnamed_addr constant [9 x i8] c"keyword1\00", align 1 @.str.1 = private unnamed_addr constant [9 x i8] c"keyword2\00", align 1 @.str.2 = private unnamed_addr constant [3 x i8] c"//\00", align 1 @.str.3 = private unnamed_addr constant [3 x i8] c"/*\00", align 1 -@"lexer_test.Token$token" = linkonce constant [4 x %"char[]"] [%"char[]" { ptr @.str, i64 7 }, %"char[]" { ptr @.str.1, i64 8 }, %"char[]" { ptr @.str.2, i64 2 }, %"char[]" { ptr @.str.3, i64 2 }], align 8 +@"lexer_test.Token$token" = linkonce constant [4 x %"char[]"] [%"char[]" { ptr @.str, i64 8 }, %"char[]" { ptr @.str.1, i64 8 }, %"char[]" { ptr @.str.2, i64 2 }, %"char[]" { ptr @.str.3, i64 2 }], align 8 @"$ct.lexer_test.Comment" = linkonce global { i8, i64, ptr, i64, i64, i64, [2 x %"char[]"] } { i8 8, i64 0, ptr null, i64 1, i64 ptrtoint (ptr @"$ct.char" to i64), i64 2, [2 x %"char[]"] [%"char[]" { ptr @.enum.SINGLE, i64 6 }, %"char[]" { ptr @.enum.MULTI, i64 5 }] }, align 8 @"lexer_test.Comment$start" = linkonce constant [2 x i8] c"\02\03", align 1 @.str.4 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1 diff --git a/test/unit/stdlib/core/string.c3 b/test/unit/stdlib/core/string.c3 index e84932fe7..4f3fb580e 100644 --- a/test/unit/stdlib/core/string.c3 +++ b/test/unit/stdlib/core/string.c3 @@ -273,7 +273,7 @@ fn void contains_char() assert(!test.contains_char('x')); } -fn void test_base_13_convesion() +fn void test_base_13_conversion() { assert("13".to_long(13)!! == 13 + 3); assert("1a".to_long(13)!! == 13 + 10); @@ -382,4 +382,4 @@ fn void test_snake_pascal_self_modify() s2.convert_snake_to_pascal(); test::eq(s2, s[1]); } -} \ No newline at end of file +} diff --git a/test/unit/stdlib/libc/libc.c3 b/test/unit/stdlib/libc/libc.c3 index aa0b88e78..9c55019ff 100644 --- a/test/unit/stdlib/libc/libc.c3 +++ b/test/unit/stdlib/libc/libc.c3 @@ -135,8 +135,8 @@ fn void bsearch() @test key = 6; found = (CInt*) libc::bsearch(&key, int_ar, 7, CInt.sizeof, &compare_cint); assert(*found == 6); - CInt non_existant_key = 12; - found = (CInt*) libc::bsearch(&non_existant_key, int_ar, 7, CInt.sizeof, &compare_cint); + CInt non_existent_key = 12; + found = (CInt*) libc::bsearch(&non_existent_key, int_ar, 7, CInt.sizeof, &compare_cint); assert(found == null); Event[] events = {