Skip to content

Commit

Permalink
fix duplicate definition test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann committed May 27, 2024
1 parent c42ad8e commit 30c3133
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 54 deletions.
8 changes: 3 additions & 5 deletions scopegraphs/examples/records/ast.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::HashMap;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Type {
StructRef(String),
Expand All @@ -9,14 +7,14 @@ pub enum Type {
#[derive(Debug)]
pub struct RecordDef {
pub name: String,
pub fields: HashMap<String, Type>,
pub fields: Vec<(String, Type)>,
}

#[derive(Debug, Clone)]
pub enum Expr {
StructInit {
name: String,
fields: HashMap<String, Expr>,
fields: Vec<(String, Expr)>,
},
#[allow(unused)]
Add(Box<Expr>, Box<Expr>),
Expand All @@ -30,7 +28,7 @@ pub enum Expr {
in_expr: Box<Expr>,
},
LetRec {
values: HashMap<String, Expr>,
values: Vec<(String, Expr)>,
in_expr: Box<Expr>,
},
}
Expand Down
2 changes: 1 addition & 1 deletion scopegraphs/examples/records/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ mod tests {
}

#[test]
#[should_panic = "duplicate definition"]
#[should_panic = "variable did not resolve uniquely: OnlyElementError::Multiple {..}"]
fn test_letrec_shadow() {
test_example(
"record A {} main = letrec a = new A {}; a = 42; in a;",
Expand Down
7 changes: 3 additions & 4 deletions scopegraphs/examples/records/parse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::HashMap;
use winnow::ascii::multispace0;
use winnow::combinator::{alt, delimited, opt, preceded, repeat, separated, terminated};
use winnow::error::{ParserError, StrContext};
Expand Down Expand Up @@ -57,7 +56,7 @@ fn parse_field_def(input: &mut &'_ str) -> PResult<(String, Type)> {
.parse_next(input)
}

fn parse_field_defs(input: &mut &'_ str) -> PResult<HashMap<String, Type>> {
fn parse_field_defs(input: &mut &'_ str) -> PResult<Vec<(String, Type)>> {
terminated(separated(0.., ws(parse_field_def), ws(",")), opt(ws(","))).parse_next(input)
}

Expand All @@ -72,7 +71,7 @@ fn parse_field(input: &mut &'_ str) -> PResult<(String, Expr)> {
.parse_next(input)
}

fn parse_fields(input: &mut &'_ str) -> PResult<HashMap<String, Expr>> {
fn parse_fields(input: &mut &'_ str) -> PResult<Vec<(String, Expr)>> {
terminated(separated(0.., ws(parse_field), ws(",")), opt(ws(","))).parse_next(input)
}

Expand All @@ -97,7 +96,7 @@ fn parse_value(input: &mut &'_ str) -> PResult<(String, Expr)> {
.parse_next(input)
}

fn parse_values(input: &mut &'_ str) -> PResult<HashMap<String, Expr>> {
fn parse_values(input: &mut &'_ str) -> PResult<Vec<(String, Expr)>> {
repeat(0.., parse_value).parse_next(input)
}

Expand Down
44 changes: 0 additions & 44 deletions scopegraphs/examples/records/tests.rs

This file was deleted.

0 comments on commit 30c3133

Please sign in to comment.