mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
make arbitrary AccessAtIndex work
it now uses that actual layout, not a hardcoded one
This commit is contained in:
parent
f3f135eca5
commit
b93fe4e341
6 changed files with 78 additions and 147 deletions
|
@ -8,7 +8,7 @@ use roc_module::ident::{Ident, Lowercase, TagName};
|
|||
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
||||
use roc_region::all::{Located, Region};
|
||||
use roc_types::subs::{Content, ContentHash, FlatType, Subs, Variable};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::hash::Hash;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default)]
|
||||
pub struct Procs<'a> {
|
||||
|
@ -1195,7 +1195,7 @@ fn specialize_proc_body<'a>(
|
|||
|
||||
/// A pattern, including possible problems (e.g. shadowing) so that
|
||||
/// codegen can generate a runtime error if this pattern is reached.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Pattern<'a> {
|
||||
Identifier(Symbol),
|
||||
Underscore,
|
||||
|
@ -1231,76 +1231,6 @@ pub struct RecordDestruct<'a> {
|
|||
pub guard: Option<Pattern<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> Hash for Pattern<'a> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
use Pattern::*;
|
||||
|
||||
match self {
|
||||
Identifier(symbol) => {
|
||||
state.write_u8(0);
|
||||
symbol.hash(state);
|
||||
}
|
||||
Underscore => {
|
||||
state.write_u8(1);
|
||||
}
|
||||
|
||||
IntLiteral(v) => {
|
||||
state.write_u8(2);
|
||||
v.hash(state);
|
||||
}
|
||||
FloatLiteral(v) => {
|
||||
state.write_u8(3);
|
||||
v.hash(state);
|
||||
}
|
||||
BitLiteral(v) => {
|
||||
state.write_u8(4);
|
||||
v.hash(state);
|
||||
}
|
||||
EnumLiteral { tag_id, enum_size } => {
|
||||
state.write_u8(5);
|
||||
tag_id.hash(state);
|
||||
enum_size.hash(state);
|
||||
}
|
||||
StrLiteral(v) => {
|
||||
state.write_u8(6);
|
||||
v.hash(state);
|
||||
}
|
||||
|
||||
RecordDestructure(fields, _layout) => {
|
||||
state.write_u8(7);
|
||||
fields.hash(state);
|
||||
// layout is ignored!
|
||||
}
|
||||
|
||||
AppliedTag {
|
||||
tag_name,
|
||||
arguments,
|
||||
union,
|
||||
..
|
||||
} => {
|
||||
state.write_u8(8);
|
||||
tag_name.hash(state);
|
||||
for (pat, _) in arguments {
|
||||
pat.hash(state);
|
||||
}
|
||||
union.hash(state);
|
||||
// layout is ignored!
|
||||
}
|
||||
|
||||
Shadowed(region, ident) => {
|
||||
state.write_u8(9);
|
||||
region.hash(state);
|
||||
ident.hash(state);
|
||||
}
|
||||
|
||||
UnsupportedPattern(region) => {
|
||||
state.write_u8(10);
|
||||
region.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn from_can_pattern<'a>(
|
||||
env: &mut Env<'a, '_>,
|
||||
can_pattern: &roc_can::pattern::Pattern,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue