Commit Graph

2293 Commits

Author SHA1 Message Date
Christoffer Lerno
c308397ed6 Fix weak linking for windows. 2024-10-11 23:35:12 +02:00
Christoffer Lerno
0cf93a8c32 Fix test. 2024-10-11 22:13:53 +02:00
Christoffer Lerno
cba25710fe Refactor and unify linker visibility and fix issues with weak stdlib. 2024-10-11 21:45:44 +02:00
Christoffer Lerno
1b471283c9 - Don't weakly link in exe. 2024-10-11 18:11:27 +02:00
Christoffer Lerno
09fee2aa4b - Standard library is now correctly weakly linked, fixing the use of C3 .so together with executable. #1549, #1107. 2024-10-11 17:14:02 +02:00
Koni Marti
2739c86881 Add csv unit tests
Add unit tests for std::encoding::csv.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2024-10-11 16:11:45 +02:00
Christoffer Lerno
cdf67684cc Add releasenote for latest fix. 2024-10-11 13:53:29 +02:00
Koni Marti
4e5ba327fe Fix mem leak in HashMap.keys_new_list
Fix a memory leak in HashMap.key_new_list(). The custom memory allocator
will not be used, since key_new_list() will call HashMap.copy_keys()
without passing the memory allocator along. Hence, HashMap.copy_keys()
will allocate on the heap and these memory blocks will not be freed.

To fix this, pass the custom allocator to HashMap.copy_keys(). Also,
since HashMap.key_new_list() is deprecated anyways, replace it by
HashMap.copy_keys().

Affected from this leak is Object.to_format() from
std::collection::object (for an ObjectInternalMap) which is used in the
JSON parser.

The tests for the JSON parser show the memory leak:

$ c3c compile-test test/unit/stdlib/encoding
$ valgrind --leak-check=yes ./testrun
==1454708==
==1454708== HEAP SUMMARY:
==1454708==     in use at exit: 384 bytes in 8 blocks
==1454708==   total heap usage: 69 allocs, 61 frees, 528,672 bytes allocated
==1454708==
==1454708== 48 bytes in 1 blocks are definitely lost in loss record 1 of 8
==1454708==    at 0x48447A8: malloc (vg_replace_malloc.c:446)
==1454708==    by 0x12CDBF: std.core.mem.allocator.LibcAllocator.acquire (libc_allocator.c3:42)
==1454708==    by 0x1790FD: malloc_try (mem_allocator.c3:64)
==1454708==    by 0x1790FD: alloc_array_try (mem_allocator.c3:286)
==1454708==    by 0x1790FD: alloc_array (mem_allocator.c3:269)
==1454708==    by 0x1790FD: copy_keys (hashmap.c3:310)
==1454708==    by 0x1790FD: std_collections_map$String$p$std.collections.object.Object$.HashMap.key
==1454708==    by 0x14D593: std.collections.object.Object.to_format (object.c3:53)
==1454708==    by 0x164556: std.io.Formatter.print_with_function (formatter.c3:86)
==1454708==    by 0x165B49: std.io.Formatter.out_str (formatter.c3:152)
==1454708==    by 0x16E2B0: std.io.Formatter.vprintf (formatter.c3:456)
==1454708==    by 0x12696B: std.core.dstring.DString.appendf (dstring.c3:532)
==1454708==    by 0x124EA9: std.core.string.tformat (string.c3:79)
==1454708==    by 0x113C79: json_test.test_string (json.c3:34)
==1454708==    by 0x118AA1: std.core.runtime.run_tests (runtime.c3:227)
==1454708==    by 0x1190B1: std.core.runtime.default_test_runner (runtime.c3:246)
==1454708==

[..snip..]

==1454708==
==1454708== LEAK SUMMARY:
==1454708==    definitely lost: 384 bytes in 8 blocks
==1454708==    indirectly lost: 0 bytes in 0 blocks
==1454708==      possibly lost: 0 bytes in 0 blocks
==1454708==    still reachable: 0 bytes in 0 blocks
==1454708==         suppressed: 0 bytes in 0 blocks
==1454708==
==1454708== For lists of detected and suppressed errors, rerun with: -s
==1454708== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2024-10-11 13:52:34 +02:00
Christoffer Lerno
efeb9e627e Interfaces not correctly copied with generics #1545. 2024-10-11 13:26:22 +02:00
Christoffer Lerno
8e24f15d58 Cannot use void as a generic parameter #1546. Interfaces now support .ptr and .type directly without casting to any. 2024-10-11 12:10:35 +02:00
Christoffer Lerno
1adad860f4 Update AST output. 2024-10-11 11:24:01 +02:00
Christoffer Lerno
cf07570871 Improved error message when declaring a variable void!. 2024-10-11 00:15:49 +02:00
Christoffer Lerno
bf30e52993 Improved error message on invalid subscript index type #1535. 2024-10-10 14:59:16 +02:00
Christoffer Lerno
a91ddd40dd Infer now works across ternary. Crash returning struct or vector from function using ternary expression #1537. 2024-10-10 14:44:40 +02:00
Christoffer Lerno
57ecadd23e Updated CSV API 2024-10-10 14:14:24 +02:00
Christoffer Lerno
967f14148f Bug when defers and $if were combined in a macro, which would cause miscompilation. 2024-10-10 13:42:12 +02:00
Christoffer Lerno
7a6544b17c Constant bytes <=> char[] conversion should work #1514 2024-10-09 19:38:06 +02:00
Christoffer Lerno
bf59efd3f4 Fix sincos to be different on Darwin compared to other. 2024-10-09 16:14:24 +02:00
Christoffer Lerno
c1266e9d06 Compiler error when any/interface initialized using {} #1533. 2024-10-09 13:12:40 +02:00
Christoffer Lerno
557adb6ed9 Update the init function of the arena allocator. 2024-10-09 12:45:50 +02:00
Christoffer Lerno
9f10996ac7 Bug when a continue is copied in a defer. 2024-10-08 22:13:30 +02:00
Christoffer Lerno
31f48829b0 Added CBool #1530. 2024-10-08 22:00:06 +02:00
Christoffer Lerno
39d4a97e24 Fix broken sincos function. 2024-10-08 20:34:41 +02:00
Christoffer Lerno
a665978b64 Fixing some whitespace issues. 2024-10-08 19:38:31 +02:00
Koni Marti
0cc62058a9 fix(string): use heap allocator for ZString.copy
Use the heap allocator for ZString.copy() instead of the temp allocator
to stay consistent across the code base.

The temp allocator is used for ZString.tcopy().
2024-10-08 17:33:29 +02:00
Christoffer Lerno
7dfdb9d061 Fix to ad hoc generic types. 2024-10-08 11:48:20 +02:00
Christoffer Lerno
e3ea1d5049 Deprecate @adhoc, allow non-nested ad hoc generic types. 2024-10-08 11:02:10 +02:00
Christoffer Lerno
19a96acac8 Improve error message in the case of MyInterface x = foo; #1522 2024-10-07 21:00:17 +02:00
Christoffer Lerno
80d016e076 Unintended deref of pointers with methods caused regression with hash function. 2024-10-07 20:43:37 +02:00
Fernando López Guevara
ac214b97df chore(cmake): switch from LLVM_LIBRARY_DIRS (list) to LLVM_LIBRARY_DIR for single path usage 2024-10-07 19:12:05 +02:00
Fernando López Guevara
1a948e4341 fix(time): update month 2024-10-07 19:11:14 +02:00
Christoffer Lerno
6bbc77a69c Segfault with passing a program with - using stdin. Using no module with - would reject the program. #1523 2024-10-06 12:19:13 +02:00
Denis Palashevskii
217151be8d fix int formatting in std::collections::object 2024-10-05 14:03:27 +02:00
Christoffer Lerno
2ef1465244 Improved ObjC support. 2024-10-04 23:25:51 +02:00
Christoffer Lerno
cfc1d0d8f8 Incorrect subscript resolution #1519 2024-10-04 20:50:48 +02:00
Christoffer Lerno
6fabecac1a Better error for int Foo(int a) declarations #1516 2024-10-04 18:15:06 +02:00
Christoffer Lerno
77ac864995 Unexpected compile error using a typed constant with copysign #1517 2024-10-04 18:01:57 +02:00
Christoffer Lerno
f95769541d Better error for int a[4] = .... #1518 2024-10-04 17:52:32 +02:00
Christoffer Lerno
fa4ca7944f - Add read/write to stream with big endian ints.
- Move accidently hidden "wrap_bytes".
2024-10-03 20:42:25 +02:00
Christoffer Lerno
02e9bfaf31 Separate const slice. Fix #1489. Fix const slice appending. Remove unintended print of char[] as String. Support const conversion of array -> slice. 2024-10-03 15:04:33 +02:00
Christoffer Lerno
7f66d5992f Update latest version. 2024-10-03 13:10:25 +02:00
Christoffer Lerno
84e10cf635 0.6.3 Release version. v0.6.3 2024-10-03 10:11:31 +02:00
Christoffer Lerno
1b8f8c5f5a Compiler crash when compiling c code in a library without --obj-out #1503. 2024-10-03 00:56:01 +02:00
Fernando López Guevara
131a783e89 feat(hash): added test for sha256 2024-10-02 16:55:17 +02:00
chri-k
2233f24c8f Add variants of DString.insert_at to match .append (#1510) 2024-10-02 10:22:59 +02:00
Christoffer Lerno
607a625641 Updated bigint. 2024-10-02 01:13:34 +02:00
Christoffer Lerno
9b49d19224 DString reverse and an initial BigInt implementation (untested), 2024-10-01 22:51:48 +02:00
Christoffer Lerno
46ae4353e0 Assume XTensa in 21+ instead. 2024-10-01 16:06:23 +02:00
Christoffer Lerno
44fcba2e3a Remove LLVM 20 2024-10-01 15:58:23 +02:00
Christoffer Lerno
f434795ee5 Test enable 19 and 20 2024-10-01 15:51:44 +02:00