Skip to content

Type system first draft - #232

Open
JonatanWaern wants to merge 5 commits into
mainfrom
type-system
Open

Type system first draft#232
JonatanWaern wants to merge 5 commits into
mainfrom
type-system

Conversation

@JonatanWaern

Copy link
Copy Markdown
Contributor

Supports first layer of type semantics and goto def/ref/decl stuff. Does not yet support cast-checking or can-store semantics

  • Rename variants of basetypecontent
  • Lookup tests for types
  • Fix bug in template cycle detection
  • Type system semantics
  • Allow vect declarations in cdecl modifiers

Makes the naming slightly more consistent
Signed-off-by: Jonatan Waern
Signed-off-by: Jonatan Waern
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Integer parsing, function equivalence, and layout/template type navigation contain correctness defects.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Introduces the first semantic DML type system and integrates it with symbol lookup, diagnostics, and LSP navigation.

Changes:

  • Adds unresolved/resolved type models, typedef resolution, equivalence checks, and diagnostics.
  • Adds goto-type-definition and typed member navigation.
  • Expands annotation-based lookup/error tests and makes template-cycle handling deterministic.
File summaries
File Description
tests/test_files/type_shadow_lookup.dml Tests separate type/value namespaces.
tests/test_files/type_lookup.dml Tests type and member navigation.
tests/test_files/goto_impl_test.dml Updates template-as-type expectations.
tests/test_files/extern_typedef_unknown_type.dml Tests unknown extern typedef types.
tests/test_files/errors_unknown_type.dml Tests unknown-type diagnostics.
tests/test_files/errors_typedef_self_ref_pointer.dml Tests pointer-mediated recursion.
tests/test_files/errors_typedef_duplicate.dml Tests duplicate typedef diagnostics.
tests/test_files/errors_typedef_cyclic.dml Tests cyclic typedef diagnostics.
tests/test_files/errors_templates_traits.dml Tests template/type collisions and overrides.
tests/test_files/errors_template_cycle.dml Tests template-cycle reporting.
tests/test_files/errors_object_params.dml Tests parameter diagnostics.
tests/test_files/errors_methods.dml Tests method type and override diagnostics.
tests/test_files/errors_isolated_misc.dml Tests structural diagnostics.
tests/test_files/errors_builtin_type_lookup.dml Exercises builtin type resolution.
tests/test_files/errors_bad_version.dml Tests unsupported-version reporting.
tests/lsp_lookup_tests.rs Adds goto-type-definition test support.
tests/error_reporting_tests.rs Adds annotation-driven diagnostic testing.
src/server/mod.rs Advertises and registers type-definition support.
src/server/dispatch.rs Adds type-definition dispatch.
src/lib.rs Adjusts internal-error macro expansion.
src/analysis/templating/types.rs Implements resolved type semantics and storage.
src/analysis/templating/traits.rs Resolves trait member and method types.
src/analysis/templating/topology.rs Fixes deterministic template-cycle handling.
src/analysis/templating/objects.rs Propagates resolved types through objects.
src/analysis/templating/mod.rs Updates declarations to resolved types.
src/analysis/templating/methods.rs Adds method type-equivalence validation.
src/analysis/symbols.rs Associates resolved types with symbols.
src/analysis/structure/types.rs Implements unresolved type parsing and resolution.
src/analysis/structure/toplevel.rs Exposes typedefs as symbols.
src/analysis/structure/statements.rs Updates derives for new type structures.
src/analysis/structure/objects.rs Stores unresolved types in declarations.
src/analysis/structure/mod.rs Adds structural parsing test helpers.
src/analysis/structure/expressions.rs Stores unresolved expression types.
src/analysis/reference.rs Extends global-reference access.
src/analysis/parsing/types.rs Renames type variants and finds field containers.
src/analysis/parsing/tree.rs Enables AST node downcasting.
src/analysis/mod.rs Integrates type storage and member symbols.
src/actions/semantic_lookup.rs Implements typed semantic lookup.
src/actions/requests.rs Handles LSP type-definition requests.
CHANGELOG.md Documents type-system and cycle fixes.
Review details
  • Files reviewed: 40/40 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

};
match kind {
// A typedef is its own type-definition.
DMLSymbolKind::Typedef => {
Comment thread src/analysis/mod.rs
Comment on lines +1435 to +1439
DMLConcreteType::StructType(st) =>
return Some(FieldContainer::Struct(st.clone())),
DMLConcreteType::Trait(t) =>
return Some(FieldContainer::Trait(t.clone())),
other => other.peel_one()?.clone(),
file: FileSpec<'a>) -> Option<UnresolvedType> {
lazy_static! {
static ref INT_RE: Regex =
Regex::new(r"(u?)int([1-5][0-9]?|6[0-4]?|[789])(_be_t|_le_t)?$")
.unwrap();
}
if let Some(captures) = INT_RE.captures(name) {
let signed = captures.get(1).is_none();
}
};
let endianness = captures.get(3).map(
|en|if en.as_str() == "be_t" { Endianness::BE }
Comment on lines +334 to +339
self.base.equivalent(&other.base)
&& self.arg_types.len() == other.arg_types.len()
&& self.arg_types.iter().zip(
other.arg_types.iter()).all(
|(ty1, ty2)|dmltype_equivalent(ty1, ty2))
&& dmltype_equivalent(&self.return_ty, &other.return_ty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants