Skip to content

Commit

Permalink
Make array type notation and slice notation nicer (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep authored Sep 12, 2023
1 parent bba2b3f commit 38605d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions crates/web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ pub fn pprint(f: &Func) -> Result<String, JsError> {
writeln!(&mut s, "x{}[{}]", tuple.var(), member.member())?
}
rose::Expr::Slice { array, index } => {
writeln!(&mut s, "x{}![x{}]", array.var(), index.var())?
writeln!(&mut s, "&x{}[x{}]", array.var(), index.var())?
}
rose::Expr::Field { tuple, member } => {
writeln!(&mut s, "x{}![{}]", tuple.var(), member.member())?
writeln!(&mut s, "&x{}[{}]", tuple.var(), member.member())?
}
rose::Expr::Unary { op, arg } => match op {
rose::Unop::Not => writeln!(&mut s, "not x{}", arg.var())?,
Expand Down Expand Up @@ -558,9 +558,7 @@ pub fn pprint(f: &Func) -> Result<String, JsError> {
rose::Ty::Fin { size } => writeln!(&mut s, "{size}")?,
rose::Ty::Generic { id } => writeln!(&mut s, "G{}", id.generic())?,
rose::Ty::Ref { inner } => writeln!(&mut s, "&T{}", inner.ty())?,
rose::Ty::Array { index, elem } => {
writeln!(&mut s, "[T{}; T{}]", elem.ty(), index.ty())?
}
rose::Ty::Array { index, elem } => writeln!(&mut s, "[T{}]T{}", index.ty(), elem.ty())?,
rose::Ty::Tuple { members } => {
write!(&mut s, "(")?;
print_elems(&mut s, 'T', members.iter().map(|member| member.ty()))?;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/impl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ T1 = Bool
`
T0 = 3
T1 = F64
T2 = [T1; T0]
T2 = [T0]T1
(x0: T2, x1: T2) -> T2 {
x6: T2 = for x2: T0 {
x3: T1 = x0[x2]
Expand Down

0 comments on commit 38605d9

Please sign in to comment.