Commit Graph

1292 Commits

Author SHA1 Message Date
kalsprite
40fd892cf5 Reject a named asm template used as a value instead of aborting the compiler 2026-08-24 00:27:26 -07:00
gingerBill
2508a29376 Correctly check constant value indexing on constants 2026-08-23 11:48:24 +01:00
kalsprite
ef1c5fe675 Fix compiler segfault on a bare in a type position call 2026-08-21 17:54:13 -07:00
Michael Tesar
7d02788257 Fix reordered compound literal comparison 2026-08-21 00:46:47 +02:00
Jeroen van Rijn
ec04cee25e Merge pull request #7407 from karl-zylinski/feat/zero-value-suggestion
Better hints when assigning or comparing to `0` when it is not allowed
2026-08-20 16:26:59 +02:00
Karl Zylinski
107f7ba313 Give better hints for what to write instead of 0 when you do x = 0 or x == 0 where 0 is not valid. Here are the rules for how it hints:
string -> ""
bool -> false
bit_set -> {}
anything with a nil -> nil
everything else -> {}

This adds a hint for structs, arrays, matrices, bit_fields, `#no_nil` unions, `rawptr`, `typeid`, the four string types and `bool`. A `bit_set` now suggests `{}` rather than `nil`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 16:13:08 +02:00
Jeroen van Rijn
442197794f Merge pull request #7404 from Kelimion/format-warning
Address printf format warning
2026-08-20 12:54:55 +02:00
Jeroen van Rijn
8a042532a5 Silence printf warnings 2026-08-20 12:37:28 +02:00
Karl Zylinski
fab2b2e85c Restore the Did you want 'nil'? diagnostic everywhere
`convert_untyped_error` sets `operand->mode = Addressing_Invalid` as its last
statement. Every call site assigns it on the line just before the call too,
which is dead except for one side effect: it suppresses the `Did you want
'nil'?` hint, gated on `operand->mode == Addressing_Constant`.

PR 7403 removed the assignment at the union call site. This removes the
remaining 10 in `convert_to_typed`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 12:26:54 +02:00
Karl Zylinski
a1fb44f4d1 Remove the os.Error == 0 compatibility hack
The hack made `0` legal against `os.Error` by blanking the constant's
`ExactValue` via `update_untyped_expr_value`, which is a silent no-op when
the expression has not been registered as an untyped expression yet. Since
#7087, `check_expr_base` calls `convert_to_typed` before `add_untyped` runs,
so the blanking is lost and the backend receives a constant typed `os.Error`
still holding integer `0` with no variant type, tripping
`GB_ASSERT_MSG(value_type != nullptr)` in `lb_const_value`.

Also drop the redundant `operand->mode = Addressing_Invalid;` before the
union `convert_untyped_error` call, which revives the `Did you want 'nil'?`
hint, and guard that hint on `type_has_nil` and an Integer/Float zero.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 11:45:50 +02:00
gingerBill
73bb97ceb4 Merge pull request #7394 from mfbulut/fix/or-else-diverging-single
Fix or_else diverging with single return value
2026-08-20 10:30:59 +02:00
korvahkh
02246ac6fd Implement fixes for constant unions
Note that with this commit, casting through
multiply-nested unions is forbidden, e.g.
```
U :: union {int, V}
V :: union {bool}
x: U = true
```
does not compile.
(Previously the compiler would simply crash)

This is to avoid situations where adding variants
can lead to unexpected changes in the value.

For example if `U` is changed to have a `bool`
variant of its own:
```
U :: union {int, bool, V}
```
Then `x: U = true` would equal
`U(true)` instead of `U(V(true))`.

Single-variant unions are exempt, primarily to
improve the ergonomics of `Maybe` in cases like:
```
x: Maybe(union{int, bool}) = 1
```

Fix #6100
Fix #6699
Fix #6895
Fix #6896
Fix #6897
Fix #7036
Fix #7083
Fix #7091
2026-08-19 20:12:56 -05:00
kalsprite
f17c86d936 diagnostics: let compiler check error() fmt strings + fixes 2026-08-19 15:39:39 -07:00
Mustafa Furkan Bulut
581d20c606 Allow 'or_else' in diverging single-return 2026-08-20 00:57:10 +03:00
Jeroen van Rijn
b7944229e5 Merge pull request #7385 from kalsprite/bit_field_value_range
bitfield: a constant is range-checked only while it is untyped
2026-08-19 20:48:58 +02:00
kalsprite
8c239a8f43 range check bitfield fields for untyped constants 2026-08-19 10:52:58 -07:00
gingerBill
9870cd4c36 Merge pull request #7271 from odin-lang/bill/inline-asm
`asm` templates
2026-08-18 19:19:40 +02:00
gingerBill
d06c25cada Restrict usage of asm templates to be declarations or called directly 2026-08-18 15:01:49 +01:00
gingerBill
a86e523053 Allow for inlineable asm calls 2026-08-18 14:57:34 +01:00
kalsprite
71d8e79806 checker: do not register map runtime dependencies under 2026-08-17 20:22:25 -07:00
gingerBill
c3b2029f64 Support asm template groups 2026-08-17 19:54:21 +01:00
gingerBill
1f2234a4b2 Merge branch 'master' into bill/inline-asm 2026-08-17 11:44:14 +01:00
kalsprite
72d1829fec #any_int range check constants 2026-08-16 22:08:52 -07:00
Jeroen van Rijn
3eeda58634 Merge pull request #7344 from kalsprite/simd_builtin_diagnostics
simd: enforce the `#simd` construction rules and stop two crashes
2026-08-16 12:17:39 +02:00
kalsprite
a7029ef7b6 bitset subset 2026-08-15 23:25:13 -07:00
kalsprite
e53fc6a879 simd [?] type fix; count recovery 2026-08-15 22:23:15 -07:00
gingerBill
cb903df235 #side_effects -> #volatile; Remove dead code 2026-08-13 10:03:00 +01:00
gingerBill
c085a46185 Move #side_effects and #align_stack to the specification list 2026-08-12 23:40:57 +01:00
Mihail Moskov
6a81351de3 fixes float to 128-bit int/uint conversion 2026-08-12 19:25:46 +03:00
gingerBill
8632a240fd Merge pull request #7313 from kalsprite/matrix_type_hint
check_matrix_type_hint: require the element type and layout to match
2026-08-12 13:25:25 +02:00
kalsprite
f053a40359 check_matrix_type_hint: require the element type and layout to match 2026-08-11 23:07:07 -07:00
kalsprite
973d90d7b1 enforce matrix size limits on mul; overflow dims 2026-08-11 21:31:36 -07:00
corley
87912a8b88 fixes range loop over array elements in soa containers 2026-08-11 03:20:13 +03:00
Jeroen van Rijn
3ac03e27b2 Merge pull request #7270 from corleypc/soa-array-elem-indexing-fix
Fixes chain indexing for array elements in soa containers
2026-08-09 21:55:47 +02:00
corley
e374541599 fixes chained indexing for soa containers with array element type 2026-08-09 22:23:32 +03:00
kalsprite
1a631b2f3f Fix constant string16 carrying UTF-8, and inverted slice indices reaching substring (#7268)
* str16 fix

* remove stale call
2026-08-09 21:22:13 +02:00
gingerBill
25ce7e87de Correctly type check asm template parameters 2026-08-09 18:52:57 +01:00
gingerBill
5ac28cdecd Begin work on semantically type checking asm templates 2026-08-09 18:24:56 +01:00
corley
7b45adf8e9 fixes swizzling for array elements in soa arrays/slices 2026-08-09 03:17:04 +03:00
kalsprite
3756aae0f8 incorp specialized-vs-generic poly 2026-08-07 17:58:35 -07:00
kalsprite
b475525997 Merge branch 'master' into poly 2026-08-07 17:41:30 -07:00
kalsprite
6276f6e12f src/check_expr.cpp 2026-08-06 21:51:03 -07:00
kalsprite
8b56b15ee2 make value poly score top 2026-08-06 21:05:54 -07:00
gingerBill
cce7159a55 Merge pull request #7208 from Taylbr/poly-proc-fix
Fix: Polymorphic procedures resolving to nil + further fixes
2026-08-05 16:56:34 +02:00
Jeroen van Rijn
9876fc3b9b Merge pull request #7226 from kalsprite/prefix
crash fix on poly
2026-08-05 12:44:31 +02:00
kalsprite
ab220ecee7 scoring experiment 2026-08-04 20:10:01 -07:00
kalsprite
91aec259c0 crash fix on poly 2026-08-04 19:15:24 -07:00
Jeroen van Rijn
e8e12a24b5 Merge pull request #7225 from kalsprite/field_list
minor typos
2026-08-05 04:06:05 +02:00
kalsprite
29c9c132b0 minor typos 2026-08-04 18:49:33 -07:00
Jeroen van Rijn
5c96963ec6 Merge pull request #7222 from kalsprite/header_suppressed
fix new line suppression
2026-08-05 03:37:21 +02:00