Skip to content

Commit

Permalink
Fixes issue 668
Browse files Browse the repository at this point in the history
The error message for default args was added to a Node that was then removed from the AST.
This fixes that and ensures the error is only reported once.
  • Loading branch information
mjp41 committed Apr 23, 2024
1 parent fc3c6df commit 0fea488
Show file tree
Hide file tree
Showing 14 changed files with 2,390 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ option(VERONA_GENERATE_LAUNCH_JSON "Generate a launch.json file for debugging in
FetchContent_Declare(
trieste
GIT_REPOSITORY https://github.com/microsoft/trieste
GIT_TAG 1e1448ca9e4ac158492bf8dbbd86b407c452fc0c
GIT_TAG f63eda3dddedaf65def0f237b566fa7e239e6a1c
GIT_SHALLOW FALSE
)

Expand Down
7 changes: 4 additions & 3 deletions src/passes/defaultargs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ namespace verona
{
if (has_default)
{
params->replace(
param,
new_params <<
err(
param,
"Can't put a parameter with no default value after a "
"parameter with one"));
"parameter with one");
// Do not process further to prevent duplicate errors.
break;
}
}
else
Expand Down
40 changes: 40 additions & 0 deletions testsuite/verona_nostdlib/issues/668/668.verona
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Default args need to be later arguments
class None0
{
test(x : None0, y : None0) : None0
{
x
}
}

class None1
{
test(x : None1 = None1, y : None1) : None1
{
x
}
}

class None2
{
test(x : None2, y : None2 = None2) : None2
{
x
}
}

class None3
{
test(x : None3 = None3, y : None3 = None3) : None3
{
x
}
}

class None4
{
test(x : None4 = None4, y : None4, z : None4 = None4) : None4
{
x
}
}
137 changes: 137 additions & 0 deletions testsuite/verona_nostdlib/issues/668/668_out/00_parse.trieste
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Verona
parse
(top
{}
(file
(group
(class
{})
(ident 5:None0)
(brace
(group
(ident 4:test)
(paren
(list
(group
(ident 1:x)
(colon)
(ident 5:None0))
(group
(ident 1:y)
(colon)
(ident 5:None0))))
(colon)
(ident 5:None0)
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None1)
(brace
(group
(ident 4:test)
(paren
(list
(equals
(group
(ident 1:x)
(colon)
(ident 5:None1))
(group
(ident 5:None1)))
(group
(ident 1:y)
(colon)
(ident 5:None1))))
(colon)
(ident 5:None1)
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None2)
(brace
(group
(ident 4:test)
(paren
(list
(group
(ident 1:x)
(colon)
(ident 5:None2))
(equals
(group
(ident 1:y)
(colon)
(ident 5:None2))
(group
(ident 5:None2)))))
(colon)
(ident 5:None2)
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None3)
(brace
(group
(ident 4:test)
(paren
(list
(equals
(group
(ident 1:x)
(colon)
(ident 5:None3))
(group
(ident 5:None3)))
(equals
(group
(ident 1:y)
(colon)
(ident 5:None3))
(group
(ident 5:None3)))))
(colon)
(ident 5:None3)
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None4)
(brace
(group
(ident 4:test)
(paren
(list
(equals
(group
(ident 1:x)
(colon)
(ident 5:None4))
(group
(ident 5:None4)))
(group
(ident 1:y)
(colon)
(ident 5:None4))
(equals
(group
(ident 1:z)
(colon)
(ident 5:None4))
(group
(ident 5:None4)))))
(colon)
(ident 5:None4)
(brace
(group
(ident 1:x))))))))
146 changes: 146 additions & 0 deletions testsuite/verona_nostdlib/issues/668/668_out/01_modules.trieste
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
Verona
modules
(top
{}
(group
(class
{})
(ident 3:668)
(brace
(group
(use)
(ident 3:std)
(doublecolon)
(ident 7:builtin))
(group
(class
{})
(ident 5:None0)
(brace
(group
(ident 4:test)
(paren
(list
(group
(ident 1:x)
(type
(ident 5:None0)))
(group
(ident 1:y)
(type
(ident 5:None0)))))
(type
(ident 5:None0))
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None1)
(brace
(group
(ident 4:test)
(paren
(list
(equals
(group
(ident 1:x)
(type
(ident 5:None1)))
(group
(ident 5:None1)))
(group
(ident 1:y)
(type
(ident 5:None1)))))
(type
(ident 5:None1))
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None2)
(brace
(group
(ident 4:test)
(paren
(list
(group
(ident 1:x)
(type
(ident 5:None2)))
(equals
(group
(ident 1:y)
(type
(ident 5:None2)))
(group
(ident 5:None2)))))
(type
(ident 5:None2))
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None3)
(brace
(group
(ident 4:test)
(paren
(list
(equals
(group
(ident 1:x)
(type
(ident 5:None3)))
(group
(ident 5:None3)))
(equals
(group
(ident 1:y)
(type
(ident 5:None3)))
(group
(ident 5:None3)))))
(type
(ident 5:None3))
(brace
(group
(ident 1:x))))))
(group
(class
{})
(ident 5:None4)
(brace
(group
(ident 4:test)
(paren
(list
(equals
(group
(ident 1:x)
(type
(ident 5:None4)))
(group
(ident 5:None4)))
(group
(ident 1:y)
(type
(ident 5:None4)))
(equals
(group
(ident 1:z)
(type
(ident 5:None4)))
(group
(ident 5:None4)))))
(type
(ident 5:None4))
(brace
(group
(ident 1:x)))))))))
Loading

0 comments on commit 0fea488

Please sign in to comment.