Skip to content

Commit

Permalink
frontend: Add IntoIterator and Iterator traits to prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Feb 7, 2025
1 parent dce87ae commit 45a564a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dora-frontend/src/stdlib_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ pub fn setup_prelude(sa: &mut Sema) {
"std::unreachable",
"std::assert",
"std::primitives::Result",
"std::traits::IntoIterator",
"std::traits::Iterator",
];

let mut prelude_table = SymTable::new();

for name in &symbols {
let sym = resolve_path(sa, name);
let name = final_path_name(sa, name);
let old_sym = prelude_table.insert(name, sym);
let old_sym = prelude_table.insert_use(name, Visibility::Module, sym);
assert!(old_sym.is_none());
}

Expand Down
9 changes: 9 additions & 0 deletions tests/stdlib/iterator-count1.dora
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//= ignore

use std::traits::IntoIterator;
use std::traits::Iterator;

fn main() {
let x = Vec[Int]::new(1, 2, 3, 4, 5);
assert(x.iter().count() == 5);
}

0 comments on commit 45a564a

Please sign in to comment.