Repository navigation
Type system second draft (amongst other things) - #252
Open
JonatanWaern wants to merge 17 commits into
Open
JonatanWaern wants to merge 17 commits into
JonatanWaern wants to merge 17 commits into
Conversation
JonatanWaern
commented
Nov 16, 2026
Contributor
- Lookup tests for types
- Fix bug in template cycle detection
- Fuzzing refactor
- Fix infinite-loop hang on layout parsing
- Implemented type system semantics
- Split lookup tests into smaller ones
- Lot's of bug fixes both to type system and in general
- Allow general identifiers, rather than tokens, in many ident slots
- Fixed issue where a duplicated template could cause internal error logs
- Suppressed internal errors in some cases where context chains are expected to fail
- Do not report collisions, or construct symbols for, index variables declared as _
- diagnostic sorting corrections
- Type system changelog
- Improvements around error reports
Signed-off-by: Jonatan Waern
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
- Fix incorrect token range for memoized error report - Extend dup member name check to struct and layout - check bitfield width values - fix initializer counting to work off of AST - Fix member access stripping for -> - Fix struct member lookups - Add support for anonymous struct lookups - Add types to externs and typed params - Add support for lookups inside template types - Fix internal error on member access of extern - Fix bugs around goto-def on local/arg declarations - Fix around implement objects, separating out goto-def and goto-type-def targets - Fix nested scopes on method bodys - Fix scoping of switch statement locals - Add duplicate name error for locals - Add reporting of unknown type names - Move struct equality comparison to use declaration AST, rather than underlying semantics of the type - Moved type comparison to fuzzy style, with future allowance for turning on strict checking - Fix errors in self-referential typedef comparison - Turn off truncation warnings - Add error when incorrectly overriding a method with mismatching independent, startup, or memoized - Add reporting of ambiguous method overrides - Fix reporting location for non-default overidden error - Narrow down trait-level checks to only trait-level members - Let template members semantically overwrite inherited ones, gives better diagnostics - Report conflicting parameter assignment even when deep in override chain - Give error when duping index variable names - Match object-level error message reporting to DMLC style (use the message if available) - Fix various cases where errors could be reported twice - Add @diag annotation to tests, allowing expected diagnostic errors - Add various tests Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
…ected to fail - When looking up in an object behind a known-false #if (actually, just a failing lookup behind any #if) - When looking up in an object shadowed by a non-comp object Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
…eclared as _ Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Closed
There was a problem hiding this comment.
🟡 Changes recommended
Layout recovery can enter a non-consuming loop after a missing semicolon, causing analysis to hang on malformed input.
4 open issues
What changed in this PR
This PR expands the DML language server’s type model, adds type-definition navigation and conservative type checking, and improves parser recovery and diagnostics.
Changes:
- Adds structured type information and navigation through typedefs, members, pointers, arrays, and interfaces.
- Extends type, inheritance, scope, and declaration diagnostics with focused regression fixtures.
- Shares the parser subprocess runner, adds recovery tests, and makes diagnostic ordering deterministic.
| File | Description |
|---|---|
| tests/test_files/type_variables.dml | Tests variable types, initializers, and navigation. |
| tests/test_files/type_template_types.dml | Tests templates used as types. |
| tests/test_files/type_switch_scope.dml | Tests type checking across switch scopes. |
| tests/test_files/type_structs.dml | Tests struct fields and recursive pointers. |
| tests/test_files/type_returns.dml | Tests return types and value counts. |
| tests/test_files/type_overrides.dml | Tests incompatible override argument types. |
| tests/test_files/type_narrowing.dml | Covers narrowing behavior and disabled warnings. |
| tests/test_files/type_name_lookup.dml | Tests typedef name lookup. |
| tests/test_files/type_method_calls.dml | Tests call arguments and result bindings. |
| tests/test_files/type_member_access.dml | Tests nested member and indexed navigation. |
| tests/test_files/type_interfaces.dml | Tests interface implementation navigation. |
| tests/test_files/type_definitions.dml | Distinguishes definition and type-definition navigation. |
| tests/test_files/type_default_calls.dml | Tests default-call types and overridden bodies. |
| tests/test_files/type_assignments.dml | Tests tuple, chained, and bitfield assignments. |
| tests/test_files/type_arrays.dml | Tests array initializer types and lengths. |
| tests/test_files/repeated_externs.dml | Adds type navigation alongside repeated extern lookup. |
| tests/test_files/multi_level.dml | Adds type navigation to inheritance fixtures. |
| tests/test_files/lookup_scopes.dml | Tests local scopes, duplicates, and hook bindings. |
| tests/test_files/lookup_misc.dml | Covers less common declaration and expression lookups. |
| tests/test_files/imported_file.dml | Adds imported typedef navigation coverage. |
| tests/test_files/goto_impl_test.dml | Enables template-type reference expectations. |
| tests/test_files/duplicate_template_import.dml | Supplies an imported duplicate-template fixture. |
| tests/test_files/duplicate_template_device.dml | Exercises duplicate templates across imports. |
| tests/test_files/diag_types.dml | Tests unknown types and type declaration errors. |
| tests/test_files/diag_structure.dml | Tests structural and parser diagnostics. |
| tests/test_files/diag_parameters.dml | Tests parameter resolution and override conflicts. |
| tests/test_files/diag_objects.dml | Tests object collisions and conditional errors. |
| tests/test_files/diag_methods.dml | Tests method inheritance and override diagnostics. |
| tests/test_files/cross_file_main.dml | Adds cross-file type navigation assertions. |
| tests/test_files/conditional_conflicts.dml | Adds navigation coverage for conditional declarations. |
| tests/test_files/basic_lookup.dml | Extends basic lookup with type-definition assertions. |
| tests/parser_recovery_tests.rs | Adds timeout-based malformed-delimiter regressions. |
| tests/fuzzing.rs | Reuses the shared parser runner. |
| tests/common/parser_runner.rs | Centralizes subprocess execution and timeout handling. |
| src/server/mod.rs | Registers and advertises type-definition support. |
| src/server/dispatch.rs | Dispatches type-definition requests. |
| src/dfa/client.rs | Stores diagnostics in ordered file maps. |
| src/analysis/templating/traits.rs | Adds type-aware trait processing and override handling. |
| src/analysis/templating/topology.rs | Passes type data and refines cycle filtering. |
| src/analysis/templating/objects.rs | Extends object validation and method-body checking. |
| src/analysis/templating/mod.rs | Retains declaration type syntax. |
| src/analysis/templating/evaluation.rs | Adds typed expression results and resolver hooks. |
| src/analysis/symbols.rs | Tracks type identities, members, and indirections. |
| src/analysis/structure/types.rs | Replaces placeholder spans with structured types. |
| src/analysis/structure/toplevel.rs | Tracks conditional contexts and exposes type symbols. |
| src/analysis/structure/statements.rs | Represents hook bindings as scoped symbols. |
| src/analysis/structure/objects.rs | Retains method qualifiers and refines declarations. |
| src/analysis/structure/expressions.rs | Exposes integer values as i128. |
| src/analysis/reference.rs | Preserves member operators and indexing in references. |
| src/analysis/parsing/types.rs | Improves layout recovery and member validation. |
| src/analysis/parsing/structure.rs | Broadens identifiers and corrects diagnostic spans. |
| src/analysis/parsing/statement.rs | Accepts keyword identifiers in hook bindings. |
| src/analysis/parsing/misc.rs | Expands the accepted identifier keywords. |
| src/analysis/parsing/expression.rs | Preserves pointer access and indexed references. |
| src/actions/semantic_lookup.rs | Resolves type-definition locations. |
| src/actions/requests.rs | Implements type-definition request handling. |
| src/actions/mod.rs | Sorts published diagnostics deterministically. |
| CHANGELOG.md | Documents type support and diagnostic improvements. |
| Cargo.toml | Registers feature-gated parser recovery tests. |
Review effort: Balanced
| let semi = list_context.expect_next_kind( | ||
| stream, TokenKind::SemiColon); | ||
| fields.push((field, semi)); | ||
| cont = new_context.peek_kind(stream).is_some_and(|t|CDecl::first_token_matcher(t) || t == TokenKind::SemiColon); |
Comment on lines
+3083
to
+3085
| let live = live && method.get_decl().calls_default; | ||
| for method in default.flat_refs() { | ||
| collect_method_chain(method, live, seen, methods); |
| method, true, &mut seen_methods, &mut methods_to_check); | ||
| } | ||
| for (method, live) in methods_to_check { | ||
| check_method_body_types(&method, object, types, live, report); |
Comment on lines
+668
to
+671
| } else if !m1.is_abstract() | ||
| && own_methods.contains(&name) { | ||
| // Our own definition overrides both | ||
| map.insert(name, implr); |
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
- Removed blanket type limitations - Add limitations specifically for `typeof(x) var` declarations and `call().x` references Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
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.

