Skip to content
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
2 changes: 1 addition & 1 deletion core/compiler/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ impl<'a> AstTransformer for VarIdTyPass<'a> {
if args.posargs.len() == 2 {
let seqty = Ty::Seq(Box::new(args.posargs[0].ty()));
let tailty = args.posargs[1].ty();
if !(tailty == Ty::SeqNil || tailty == seqty) {
if !(tailty == Ty::SeqNil || self.is_eq_ty(&tailty, &seqty)) {
self.errors.push(StaticError {
span: self.span(args.posargs[1].span()),
kind: StaticErrorKind::IncorrectTy {
Expand Down
26 changes: 26 additions & 0 deletions core/compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mod tests {
const ARGON_ROUNDING: &str = concatcp!(EXAMPLES_DIR, "/rounding/lib.ar");
const ARGON_FLIPPED_RECT: &str = concatcp!(EXAMPLES_DIR, "/flipped_rect/lib.ar");
const ARGON_SEQ_BASIC: &str = concatcp!(EXAMPLES_DIR, "/seq_basic/lib.ar");
const ARGON_SEQ_ANY: &str = concatcp!(EXAMPLES_DIR, "/seq_any/lib.ar");
const ARGON_SEQ_FN: &str = concatcp!(EXAMPLES_DIR, "/seq_fn/lib.ar");
const ARGON_SEQ_RECUR: &str = concatcp!(EXAMPLES_DIR, "/seq_recur/lib.ar");
const ARGON_LUB_MATCH: &str = concatcp!(EXAMPLES_DIR, "/lub_match/lib.ar");
Expand Down Expand Up @@ -573,6 +574,31 @@ mod tests {
assert_relative_eq!(r.y1.0, 200., epsilon = EPSILON);
}

#[test]
fn argon_seq_any() {
let o = parse_workspace_with_std(ARGON_SEQ_ANY);
assert!(o.static_errors().is_empty());
let ast = o.ast();
let cells = compile(
&ast,
CompileInput {
cell: &["top"],
args: Vec::new(),
lyp_file: &PathBuf::from(BASIC_LYP),
},
);
println!("{cells:#?}");
let cells = cells.unwrap_valid();
let cell = &cells.cells[&cells.top];
assert_eq!(cell.objects.len(), 1);
let r = cell.objects.iter().find_map(|(_, v)| v.get_rect()).unwrap();
assert_eq!(r.layer.as_ref().unwrap(), "met1");
assert_relative_eq!(r.x0.0, 0., epsilon = EPSILON);
assert_relative_eq!(r.y0.0, 0., epsilon = EPSILON);
assert_relative_eq!(r.x1.0, 400., epsilon = EPSILON);
assert_relative_eq!(r.y1.0, 200., epsilon = EPSILON);
}

#[test]
fn argon_seq_fn() {
let o = parse_workspace_with_std(ARGON_SEQ_FN);
Expand Down
10 changes: 10 additions & 0 deletions examples/seq_any/lib.ar
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn prepend(lst: [Any]) -> [Float] {
cons(100., lst)
}

cell top() {
let r = rect("met1", x0=0., y0=0., x1=400.)!;
let lst = prepend(cons(500., cons(300., cons(800., cons(200., cons(1400., []))))));
let v = head(tail(tail(tail(tail(lst)))));
eq(r.y1, v);
}