feat: stdlib improvements, trait dispatch on primitives, generics soundness#71
Merged
Conversation
…inue warnings Enable dot-syntax for compiler-provided trait methods on primitive types (e.g., `a.unsafe_add(b)` instead of `UnsafeAdd::unsafe_add(a, b)`). Supports chained calls and complex receiver expressions. Convert all `IrError::Lowering(String)` to span-based `IrError::Diagnostic` for better error messages with source locations. Remove the now-unused `Lowering` variant. Emit compiler warnings for unimplemented `break`/`continue`. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…port globals - Fix monomorphization cache collision: Map<u256, u256> and Map<CustomHash, CustomSStore> no longer share cache entries (use mangled type names instead of EvmType for cache keys) - Fix composite_base propagation: struct params inferred from type sigs during inlining now get composite_base set to their value (enables field access in trait method bodies) - Add struct param memory allocation for calldata-passed struct params in contract functions (CALLDATACOPY to allocated memory region) - Add default keccak-chained derive_slot for struct types without explicit UniqueSlot impl (Solidity nested mapping convention) - Auto-import std/globals (ops, map, option, result) without explicit use - Move std/ops.edge to std/globals/ops.edge, add globals/map.edge - Add build_type_param_subst with base name fallback for mangled generics - Add tracing at trace level for method dispatch and inline param binding - Egglog tracing now requires verbosity 5 (-vvvvv) instead of 4 - Add Map<CustomHash, CustomSStore> and Map<DefaultKey, u256> e2e tests (21 map_std tests total) Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Extract `lookup_binding_for_expr()` to deduplicate scope traversal in `infer_receiver_type` and `infer_receiver_type_args` - Extract `try_compiler_stateful_dispatch()` to deduplicate the lower-receiver + lower-args + compiler_provided_stateful_method pattern - Replace `StructParamInfo` struct with simple `(String, usize)` tuple — callsite only needs name and field count, no need to clone fields Co-Authored-By: Claude Opus 4.6 <[email protected]>
…enerics soundness
- Replace starts_with("Map") checks in infer_receiver_type, infer_receiver_type_args,
and inline_function_call with Index trait impl Output type lookup
- Add trait_type_args to TraitImplInfo and GenericImplBlock for type-system-based dispatch
- Fix is_primitive_type to validate width ranges (8..=256 step 8) matching lexer rules
- Fix resolve_generic_type_name to return None on ambiguous multiple monomorphizations
- Add resolve_generic_type_name_with_args for precise resolution with type context
- Add type_sig_hint threading from VarDecl to struct instantiation for disambiguation
- Fix composite_type_args propagation in inline_function_call (was dropping to Vec::new)
- Improve error messages: "ambiguous generic type" instead of "unknown" for multi-monomorph
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
✅ Deploy Preview for edgelang ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Gas Snapshot DiffChanged (6) | Unchanged (137)
Regressions at O3 (6)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
u256.unsafe_add(b)style calls now work via trait impl lookup with span-based error messagesstarts_with("Map")checks with proper Index trait impl lookup — any user-defined type implementing Index gets the same treatmentresolve_generic_type_name()now returnsNonefor ambiguous monomorphizations instead of silently picking the first; addedtype_sig_hintthreading andresolve_generic_type_name_with_args()for precise resolutionis_primitive_type()fix: Validates width ranges matching lexer rules (u/i 8-256 step 8, bytes 1-32) instead of matching any prefixMap,ops,Option,Resultauto-imported as globalsStructParamInfoAdds a few stdlib traits:
Index allows for operator overloading of
[]syntax.UniqueSlotis a way to customize slot calculation - takes a base slot provided by the compiler. IntroduceSstore + Sloadtraits which tell the compiler what to do for loading and storing to storage. Here is an example that is in the examples/tests/test_map_std.edge:Notably: this removes
mapas a primitive and instead just represents it using the normal type system and gives users the flexibility to really get the most out of their contract.