core: refactor to use TypeVarId
and TypeVar
#414
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#414
Loading…
Reference in New Issue
No description provided.
Delete Branch "type-var-id"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Main changes are in
nac3core/src/typecheck/typedef/mod.rs
.struct TypeVarId(u32)
instead of simplyu32
.struct TypeVar { id: TypeVarId, ty: Type }
.unifier.add_ty
and others now returnTypeVar
instead of(Type, u32)
.Other notes:
insta
snapshots are updated. This is because type variable IDu32
values are now wrapped withinTypeVarId
. The output fromDebug
becomes different.The rest of the PR looks good. Do remove the
*.bc
and*.o
file, or otherwise add those to the Gitignore.@ -32,1 +31,3 @@
pub type VarMap = IndexMapping<u32>;
/// ID of a Python type variable. Specific to `nac3core`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TypeVarId(pub u32);
I don't think it's necessary to
pub
the value of theTypeVarId
. Maybe add aFrom<TypeVarId> for u32
if we want to be able to convert back to au32
value.@ -33,0 +33,4 @@
pub struct TypeVarId(pub u32);
impl fmt::Display for TypeVarId {
// NOTE: Must output the string fo the ID value. Certain unit tests rely on string comparisons.
Typo: fo -> of
@ -33,0 +55,4 @@
/// Build a [`VarMap`] from an iterator of [`TypeVar`]
///
/// The resulting [`VarMap`] wil have the same order as the input iterator.
pub fn to_var_map<I>(vars: I) -> VarMap
This might be better named as
into_var_map
.1da1bdacab
to21c62f235b
Revised. Force-pushed to remove non-source files from history.
ddef23db15
to344b959998
344b959998
to6979843431