summary refs log tree commit diff stats
path: root/compiler/sigmatch.nim
Commit message (Expand)AuthorAgeFilesLines
* fix typeRel of typeDesc (#21227)Bung2023-01-091-2/+6
* less verbose type mismatch messages (#21191)ringabout2022-12-281-17/+23
* Fix nimsuggest not suggesting fields in when theres static parameters (#21189)Jake Leahy2022-12-281-1/+1
* remove legacy code (#21134)ringabout2022-12-261-2/+0
* fix #16541 (#21148)Bung2022-12-221-0/+2
* definite assignment analysis for let (#21024)ringabout2022-12-061-2/+5
* deprecate `do:` meaning `do ():` + misc cleanup (#20927)metagn2022-12-061-0/+2
* fix #20829 Regression in int64 type matching since (#21019)Bung2022-12-061-2/+4
* Revert "fixes #20883; Unspecified generic on default value segfaults the comp...ringabout2022-12-061-2/+1
* fixes #20883; Unspecified generic on default value segfaults the compiler (#2...ringabout2022-12-011-1/+2
* tyInt tyUint fit target int bit width (#20829)Bung2022-12-011-19/+28
* fix #13790; ptr char (+friends) should not implicitly convert to cstring (#2...ringabout2022-11-241-10/+12
* fix #19149 Invalid codegen when returning var tuple from a template (#20762)Bung2022-11-061-2/+3
* fix #19700 Crash when passing a template to a generic functio… (#20567)Bung2022-10-151-0/+2
* fix #7446 Generics: type mismatch 'SomeunsignedInt or Natural' (#20522)Bung2022-10-111-2/+1
* DAA and 'out' parameters (#20506)Andreas Rumpf2022-10-061-8/+19
* Markdown code blocks part 6 (#20292)Andrey Makarov2022-08-311-3/+2
* remove a special case in sigmatch; distinct pointer types no longer match `ni...ringabout2022-08-231-2/+0
* move assertions out of system (#19599)flywind2022-03-231-0/+3
* No longer segfault when using a typeclass with a self referencing type (#19467)Jason Beetham2022-02-021-1/+2
* Fixed concept constraints for static types (#19391)Jason Beetham2022-01-151-0/+9
* Generic parameters now can constrain statics in type definitions (#19362)Jason Beetham2022-01-141-2/+12
* fixes #19015 [backport:1.6] (#19204)Andreas Rumpf2021-12-041-1/+2
* implements https://github.com/nim-lang/RFCs/issues/407 (#18793)Andreas Rumpf2021-09-031-2/+12
* fixes #16325 [backport:1.4] (#18784)Andreas Rumpf2021-09-021-2/+1
* sigmatch: support optional params with last block arg(s) (#18631)Timothee Cour2021-08-201-1/+13
* implements overloadable enum values; WIP (#18470)Andreas Rumpf2021-07-281-1/+1
* fixes #18565 (#18593)Andreas Rumpf2021-07-271-1/+3
* Make procedure mismatch more informative with pragma/call convention mismatch...Jason Beetham2021-07-061-31/+2
* fixes #16270 (#18388)Andreas Rumpf2021-06-291-2/+7
* fix range to unsigned conversion (#17754)Tanguy Cizain2021-04-171-1/+1
* -d:nimDebug: calls doAssert false instead of quit (#17739)Timothee Cour2021-04-171-1/+1
* cString => cSourceString; tyCString => tyCstring so that error msgs show cstr...Timothee Cour2021-04-171-5/+5
* iterable[T] (#17196)Timothee Cour2021-04-111-8/+23
* `--nilseqs` is now a deprecated noop (#17211)Timothee Cour2021-03-011-8/+2
* new-style concepts implementation, WIP (#15251)Andreas Rumpf2021-02-241-5/+12
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-5/+5
* [docs minor]space for code-block (#16266)flywind2020-12-061-1/+3
* rename: stmt -> typed and expr -> untyped (#15989)flywind2020-11-161-2/+2
* Correct all eggs (#15906)Miran2020-11-101-2/+2
* fix static[Slice[T]] as argument issue (#15842)cooldome2020-11-041-1/+1
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-7/+11
* sigmatch: hotfix [backport] (#15565)Andreas Rumpf2020-10-141-2/+2
* fix infinite recursion in typeRel (#15241)jcosborn2020-09-181-56/+59
* Big compiler Cleanup (#14777)Clyybber2020-08-281-33/+18
* Fix #5691 (#15158)Clyybber2020-08-271-14/+12
* fix some issues overloading with generics and inheritance (#15211)jcosborn2020-08-271-11/+34
* fix overloading issue with generic invocation (#15135)jcosborn2020-08-181-14/+1
* Use typeflag insteadClyybber2020-08-101-2/+2
* Make explicit {.nimcall.} a seperate calling conventionClyybber2020-08-081-2/+2
/span>} else if arg_matches.subcommand_matches("update").is_some() { info!("Updating post ..."); update(&db); } else if arg_matches.subcommand_matches("delete").is_some() { info!("Deleting post"); delete(&db); } list_matches(&db); } // Make sure nobody encodes narsty characters // into a message to negatively affect other // users fn str_to_utf8(str: &str) -> String { str.chars() .map(|c| { let mut buf = [0; 4]; c.encode_utf8(&mut buf).to_string() }) .collect::<String>() } fn list_matches(db: &db::Conn) { let mut stmt = db.conn.prepare("SELECT * FROM posts").unwrap(); let out = stmt .query_map(rusqlite::NO_PARAMS, |row| { let id: u32 = row.get(0)?; let title: String = row.get(1)?; let author: String = row.get(2)?; let body: String = row.get(3)?; let title = str_to_utf8(&title); let body = str_to_utf8(&body); Ok(db::Post { id, title, author, body, }) }) .unwrap(); let mut postvec = Vec::new(); out.for_each(|row| { if let Ok(post) = row { postvec.push(format!( "{}. {} -> by {}\n{}\n\n", post.id, post.title, post.author, post.body )); } }); for (i, e) in postvec.iter().enumerate() { if (postvec.len() >= 30 && i >= postvec.len() - 31) || postvec.len() < 30 { print!("{}", e); } } } fn post(db: &db::Conn) { let mut stmt = db .conn .prepare("INSERT INTO posts (title, author, body) VALUES (:title, :author, :body)") .unwrap(); println!(); println!("Title of the new post: "); let mut title = String::new(); io::stdin().read_line(&mut title).unwrap(); let title = title.trim(); let title = if title.len() > 30 { &title[..30] } else { &title }; println!(); println!("Body of the new post: "); let mut body = String::new(); io::stdin().read_line(&mut body).unwrap(); let body = body.trim(); let body = if body.len() > 500 { &body[..500] } else { &body }; let user = users::get_current_username() .unwrap() .into_string() .unwrap(); stmt.execute_named(&[(":title", &title), (":author", &user), (":body", &body)]) .unwrap(); println!(); } fn update(db: &db::Conn) { let cur_user = users::get_current_username() .unwrap() .into_string() .unwrap(); println!(); println!("ID number of your post to edit?"); let mut id_num_in = String::new(); io::stdin().read_line(&mut id_num_in).unwrap(); let id_num_in: u32 = id_num_in.trim().parse().unwrap(); let mut get_stmt = db .conn .prepare("SELECT * FROM posts WHERE id = :id") .unwrap(); let row = get_stmt .query_row_named(&[(":id", &id_num_in)], |row| { let title: String = row.get(1).unwrap(); let author = row.get(2).unwrap(); let body = row.get(3).unwrap(); Ok(vec![title, author, body]) }) .unwrap(); if cur_user != row[1] { println!(); println!("Username mismatch - can't update post!"); return; } let mut new_title = String::new(); let mut new_body = String::new(); println!("Updating post {}", id_num_in); println!(); println!("Title: {}\n\nBody: {}", row[0], row[2]); println!(); println!("Enter new title:"); io::stdin().read_line(&mut new_title).unwrap(); println!(); println!("Enter new body:"); io::stdin().read_line(&mut new_body).unwrap(); println!(); let new_title = new_title.trim(); let new_body = new_body.trim(); let title_stmt = format!("UPDATE posts SET title = :title WHERE id = {}", id_num_in); let mut stmt = db.conn.prepare(&title_stmt).unwrap(); stmt.execute_named(&[(":title", &new_title)]).unwrap(); let body_stmt = format!("UPDATE posts SET body = :body WHERE id = {}", id_num_in); let mut stmt = db.conn.prepare(&body_stmt).unwrap(); stmt.execute_named(&[(":body", &new_body)]).unwrap(); } fn delete(db: &db::Conn) { let cur_user = users::get_current_username() .unwrap() .into_string() .unwrap(); println!(); println!("ID of the post to delete?"); let mut id_num_in = String::new(); io::stdin().read_line(&mut id_num_in).unwrap(); let id_num_in: u32 = id_num_in.trim().parse().unwrap(); println!(); let del_stmt = format!("DELETE FROM posts WHERE id = {}", id_num_in); let get_stmt = format!("SELECT * FROM posts WHERE id = {}", id_num_in); let mut get_stmt = db.conn.prepare(&get_stmt).unwrap(); let mut del_stmt = db.conn.prepare(&del_stmt).unwrap(); let user_in_post: String = get_stmt .query_row(rusqlite::NO_PARAMS, |row| row.get(2)) .unwrap(); if cur_user != user_in_post { println!("Users don't match. Can't delete!"); println!(); return; } del_stmt.execute(rusqlite::NO_PARAMS).unwrap(); }