The frontend could be split into more modular parts by reducing repetition, grouping some Type variants by their behavior, and splitting out some code into separate crates
Happy Case
Reduce repetition
[ ] Use NodeInterner and Typeimpl helper functions (these functions are sometimes inlined)
[ ] Use the same field names in the AST and HIR, e.g. bounds in NoirTrait vs. trait_bounds in Trait
[ ] Use helper functions for hir_def fields and make them private, e.g. set_methods for Trait, or else consider removing those helper functions
Grouping types by behavior
Each of the types in these groups shares methods, e.g. the sized container types all evaluate their lengths to u32's, struct and tuple types both require iteration over their fields, etc.
[ ] Sized container types:
[T; N]
str<N>
fmtstr<N, T>
[ ] Struct + Tuple
[ ] Integral types:
Field
bool
()?
[ ] Arithmetic generics:
InfixExpr
CheckedCast
Constant
[ ] Type variables:
TypeVariable
NamedGeneric
Separate crates
[ ] Make a crate for all integral binary operations, including evaluation, printing, etc. (used in resolution, arithmetic generics, comptime interpreter, noirc_evaluator, and possibly other locations)
Problem
The frontend could be split into more modular parts by reducing repetition, grouping some
Type
variants by their behavior, and splitting out some code into separate cratesHappy Case
Reduce repetition
NodeInterner
andType
impl
helper functions (these functions are sometimes inlined)bounds
inNoirTrait
vs.trait_bounds
inTrait
hir_def
fields and make them private, e.g.set_methods
forTrait
, or else consider removing those helper functionsGrouping types by behavior
Each of the types in these groups shares methods, e.g. the sized container types all evaluate their lengths to
u32
's, struct and tuple types both require iteration over their fields, etc.[T; N]
str<N>
fmtstr<N, T>
Field
bool
()
?InfixExpr
CheckedCast
Constant
TypeVariable
NamedGeneric
Separate crates
comptime
interpreter,noirc_evaluator
, and possibly other locations)Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response