Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make array type notation and slice notation nicer #97

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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