Commit Graph
1382 Commits
Author SHA1 Message Date
gingerBill 93a3312a29 Remove parapoly scaffolding and fix map internal generation 2026-09-30 20:49:28 +01:00
gingerBill 47ffc56d1a Handle anonymous parapoly unions better 2026-09-30 19:44:23 +01:00
gingerBill fa8588189d Continue to flesh out the new poly-subst engine 2026-09-30 19:01:38 +01:00
gingerBill 796fd261a4 Begin work on the improving the parapoly substitution engine 2026-09-30 17:36:14 +01:00
gingerBill 3b9ef40fae Clean up comments and add more wait signal guards for union variants 2026-09-30 15:53:31 +01:00
gingerBill 3b366c9e29 Begin work on handling the wait signals correctly for union variants throughout 2026-09-30 15:32:49 +01:00
gingerBill 98fd36b0e7 Fix [$E]$T bug where you need to capture polymorphic element node before rewriting the poly in place 2026-09-30 14:49:11 +01:00
gingerBill 781d9cbd8b parapoly: fix proc-cache race, record ABBA deadlock, and over-eager poly matching
Three fixes to the parametric-polymorphism checker.

src/check_expr.cpp
- find_or_generate_polymorphic_procedure: close a check-then-act race in the
  generated-procedure cache. Both lookups ran under a shared lock that was
  released before the insert, so two threads instantiating the same
  specialization could both miss and each publish a distinct entity. Re-check
  under the exclusive lock, now held across construction and the array_add so
  find-then-publish is atomic. Factor the reuse path into
  reuse_gen_polymorphic_procedure.
- is_polymorphic_type_assignable: require BOTH components to match for maps and
  enumerated arrays (|| -> &&). The old || accepted e.g. map[int]$V against
  map[string]f32 (binding $V and deferring the key mismatch to a confusing
  assignment error); it now fails cleanly at inference. Both sides are still
  evaluated, so modify_type side effects are unchanged.

src/check_type.cpp, src/check_expr.cpp
- check_struct_type: release the originating record's gen_types mutex right after
  the instantiation is published, before checking its fields. Holding it across
  field-checking (which instantiates other records) allowed a cross-record ABBA
  deadlock between mutually-recursive generic structs instantiated concurrently;
  concurrent finders now synchronize via the existing fields_wait_signal.
  Canonicalize the instantiation name before publishing
  (set_polymorphic_record_instantiation_name) so the early release cannot expose
  a torn Named.name. Unions are left unchanged: they lack a variants-ready
  signal, so early release is not yet safe for them.
2026-09-30 14:39:47 +01:00
gingerBill bc8635dbe7 Merge pull request #7674 from louisnovy/fix-deferred-procedure-conditional-calls
Fix #5105 and #5569: Deferred call in short circuits causes LLVM codegen failure
2026-09-30 11:11:52 +01:00
Louis Novy db46204e38 Catch calls of a deferred out proc in short circuits during check 2026-09-29 19:22:01 -04:00
gingerBill 383a2fe1e5 Reject complex/quaternion component overflow to match normal floats 2026-09-29 16:34:06 +01:00
gingerBill 95df4904e8 Change struct Complex128 and struct Quaternion256 to use ExactValue elements to allow for the new Big_Rat benefits that floats get 2026-09-29 16:00:28 +01:00
gingerBill 29b681b43d Handle more cases where ExactValue_Float was being handled but not for ExactValue_Rational 2026-09-29 15:21:00 +01:00
gingerBill 19f7b5e2e2 Add f16/f32 precision checks; Fix macOS MSIZE macro collision 2026-09-29 14:53:28 +01:00
gingerBill 7b19697dcf Integrate ExactValue_Rational throughout the codebase 2026-09-29 14:38:08 +01:00
gingerBill 798be5cc0a Merge pull request #7588 from Creativty/fix/CompoundLit_OOB
Error on OOB tuple element in compound literals
2026-09-29 13:14:46 +01:00
gingerBill 8640b38899 Merge pull request #7661 from louisnovy/fix-swizzle-through-pointer
Fix #7587: full length swizzles through a pointer keeping the pointer type
2026-09-29 13:06:24 +01:00
gingerBill d5a2ff0619 Merge pull request #7658 from corleypc/must-tail-wasm-fix
Fixes #must_tail on wasm targets
2026-09-29 13:03:59 +01:00
gingerBill b153d6071c Support bit_set[E; [4]u64] style types 2026-09-29 12:17:02 +01:00
gingerBill ae63a4a4c6 Fix big integer representation of large numbers such as 98765.0e309 2026-09-29 11:41:50 +01:00
Louis Novy adc2059d36 Merge branch 'master' of https://github.com/odin-lang/Odin into fix-swizzle-through-pointer
# Conflicts:
#	tests/issues/run.bat
#	tests/issues/run.sh
2026-09-29 02:27:05 -04:00
corley a931018a24 fixes #must_tail on wasm targets 2026-09-29 01:57:49 +03:00
gingerBill 9924dcebd3 Merge pull request #7629 from Dreamshade-1911/fix/proc-lit-union-variant-compound-lit
Fix #7596 and #7511
2026-09-27 15:01:39 +01:00
Louis Novy d65d743ab7 Fix full length swizzles through a pointer keeping the pointer type 2026-09-26 22:22:42 -04:00
Fernando Nunes a5e80c7530 fix(checker): record instantiated poly proc on selector when used as a proc value 2026-09-25 07:45:33 -03:00
Fernando Nunes bc68304497 fix #7596 and #7511: proc literal as union variant in compound literal crashes backend 2026-09-25 07:08:01 -03:00
alyekypo 23cc994255 fix(checker): keep entity iteration valid across a scope map rehash
`check_scope_decls` iterates a scope's entity map while
`check_entity_decl` can insert into that same scope: a procedure alias
(`f :: e`) goes through `override_entity_in_scope`, which calls
`scope_map_insert`. The map grows at 75% load (12 of 16 slots, then 24
of 32), and `scope_map_insert` grows before it probes for the key, so
even an alias that only replaces an existing value rehashes and
reallocates the table in the middle of the iteration.

`ScopeMapIterator` re-read its map on every step while `end` had
captured the capacity at loop start, so the walk continued over the new
table under the old sentinel: it ran past the end of the reallocated
table and dereferenced whatever followed it as an `Entity *` - a nullptr
dereference for a procedure scope holding exactly 12 or 24 entities - or
it stopped at the stale end index and silently skipped every declaration
that the rehash had moved behind it, which left unused declarations
without any diagnostic at all.

The iterator now snapshots the table pointer and capacity when it is
constructed, so iteration is invariant under any insert or grow and
cannot leave the table it began on. A scope that does not grow behaves
exactly as before: the snapshot points at the same table.

Refs #7598
2026-09-21 13:13:39 +00:00
Abderrahim Indjaren d32bbfd7be fix: oversight during underflow condition
fix: incorrect message format argument for index overflow
2026-09-18 03:04:18 +01:00
Abderrahim Indjaren 09c81c8a7f fix: prevent struct crashing from tuple expansion overflow 2026-09-18 02:50:18 +01:00
Abderrahim Indjaren 02c14865ad fix: out of bounds init tuple element in CompoundLit reported as error 2026-09-18 01:58:49 +01:00
Michael Tesař a26aca2fe6 fix constant bit_field field access returning zero value 2026-09-15 22:28:53 +02:00
Sylphrena 0d49f1fed3 Add constant -> constant index 2026-09-09 20:34:41 +02:00
Sylphrena add1e6849a Improve error message for constant indexing 2026-09-09 20:28:23 +02:00
Jeroen van Rijn 1771b61ead Fix ICE 2026-09-08 15:07:54 +02:00
gingerBill 654b3a8895 asm: Generalize memory operand syntax to a flat term list
Parse `[...]` as `term { (+|-) term }` where each term is `operand [ (*|<<|>>) operand ]`.

This allows for constant-only terms to be folded in-place, especially for things like displacement.

e.g. `[p + 8*32]` means `[p + 256]`.

Term order is also free: `[8 + p]` == `[p + 8]`
2026-09-07 18:39:59 +01:00
gingerBill 07b5c2ee0f Support enable_target_feature and require_target_feature for asm templates 2026-08-31 16:39:17 +01:00
gingerBill 2f8ddd560b Merge branch 'master' into asm_immediate_constant 2026-08-25 15:28:06 +01:00
gingerBill a2d9ca8697 Remove unneeded hash maps when you can store the data directly on the nodes 2026-08-24 22:25:53 +01:00
gingerBill baf5e22e7e Merge branch 'master' into asm_immediate_constant 2026-08-24 09:34:55 +01:00
kalsprite 40fd892cf5 Reject a named asm template used as a value instead of aborting the compiler 2026-08-24 00:27:26 -07:00
kalsprite 6088dc8420 Reject a non-constant argument to an template's immediate 2026-08-23 22:22:15 -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 ZylinskiandClaude Opus 5 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 ZylinskiandClaude Opus 5 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 ZylinskiandClaude Opus 5 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