From 0fea488c1b9fe517be5c7ae587435f0d67c5110f Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Tue, 23 Apr 2024 15:49:22 +0100 Subject: [PATCH] Fixes issue 668 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. --- CMakeLists.txt | 2 +- src/passes/defaultargs.cc | 7 +- .../verona_nostdlib/issues/668/668.verona | 40 ++ .../issues/668/668_out/00_parse.trieste | 137 ++++ .../issues/668/668_out/01_modules.trieste | 146 ++++ .../issues/668/668_out/02_structure.trieste | 239 +++++++ .../issues/668/668_out/03_reference.trieste | 244 +++++++ .../668/668_out/04_conditionals.trieste | 244 +++++++ .../issues/668/668_out/05_lambda.trieste | 244 +++++++ .../issues/668/668_out/06_autocreate.trieste | 454 +++++++++++++ .../issues/668/668_out/07_defaultargs.trieste | 622 ++++++++++++++++++ .../issues/668/668_out/exit_code.txt | 1 + .../issues/668/668_out/stderr.txt | 0 .../issues/668/668_out/stdout.txt | 14 + 14 files changed, 2390 insertions(+), 4 deletions(-) create mode 100644 testsuite/verona_nostdlib/issues/668/668.verona create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/00_parse.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/01_modules.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/02_structure.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/03_reference.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/04_conditionals.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/05_lambda.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/06_autocreate.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/07_defaultargs.trieste create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/exit_code.txt create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/stderr.txt create mode 100644 testsuite/verona_nostdlib/issues/668/668_out/stdout.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 742c53d84..639d8c8fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/src/passes/defaultargs.cc b/src/passes/defaultargs.cc index 02962af3f..b89456e29 100644 --- a/src/passes/defaultargs.cc +++ b/src/passes/defaultargs.cc @@ -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 diff --git a/testsuite/verona_nostdlib/issues/668/668.verona b/testsuite/verona_nostdlib/issues/668/668.verona new file mode 100644 index 000000000..ed8c2c6a1 --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668.verona @@ -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 + } +} \ No newline at end of file diff --git a/testsuite/verona_nostdlib/issues/668/668_out/00_parse.trieste b/testsuite/verona_nostdlib/issues/668/668_out/00_parse.trieste new file mode 100644 index 000000000..9140773bf --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/00_parse.trieste @@ -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)))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/01_modules.trieste b/testsuite/verona_nostdlib/issues/668/668_out/01_modules.trieste new file mode 100644 index 000000000..e17df4d8f --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/01_modules.trieste @@ -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))))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/02_structure.trieste b/testsuite/verona_nostdlib/issues/668/668_out/02_structure.trieste new file mode 100644 index 000000000..34800542b --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/02_structure.trieste @@ -0,0 +1,239 @@ +Verona +structure +(top + { + 668 = class} + (class + { + None0 = class + None1 = class + None2 = class + None3 = class + None4 = class + include 668} + (ident 3:668) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (use + (type + (ident 3:std) + (doublecolon) + (ident 7:builtin))) + (class + { + test = function} + (ident 5:None0) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None0)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None0)) + (dontcare))) + (type + (ident 5:None0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (ident 1:x)))))) + (class + { + test = function} + (ident 5:None1) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None1)) + (block + (expr + (ident 5:None1)))) + (param + (ident 1:y) + (type + (ident 5:None1)) + (dontcare))) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (ident 1:x)))))) + (class + { + test = function} + (ident 5:None2) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None2)) + (block + (expr + (ident 5:None2))))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (ident 1:x)))))) + (class + { + test = function} + (ident 5:None3) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3)))) + (param + (ident 1:y) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3))))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (ident 1:x)))))) + (class + { + test = function} + (ident 5:None4) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param + z = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4)))) + (param + (ident 1:y) + (type + (ident 5:None4)) + (dontcare)) + (param + (ident 1:z) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4))))) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (ident 1:x))))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/03_reference.trieste b/testsuite/verona_nostdlib/issues/668/668_out/03_reference.trieste new file mode 100644 index 000000000..cb632b48b --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/03_reference.trieste @@ -0,0 +1,244 @@ +Verona +reference +(top + { + 668 = class} + (class + { + None0 = class + None1 = class + None2 = class + None3 = class + None4 = class + include 668} + (ident 3:668) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (use + (type + (ident 3:std) + (doublecolon) + (ident 7:builtin))) + (class + { + test = function} + (ident 5:None0) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None0)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None0)) + (dontcare))) + (type + (ident 5:None0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None1) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None1)) + (block + (expr + (ident 5:None1)))) + (param + (ident 1:y) + (type + (ident 5:None1)) + (dontcare))) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None2) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None2)) + (block + (expr + (ident 5:None2))))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None3) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3)))) + (param + (ident 1:y) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3))))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None4) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param + z = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4)))) + (param + (ident 1:y) + (type + (ident 5:None4)) + (dontcare)) + (param + (ident 1:z) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4))))) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x)))))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/04_conditionals.trieste b/testsuite/verona_nostdlib/issues/668/668_out/04_conditionals.trieste new file mode 100644 index 000000000..5adf2101f --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/04_conditionals.trieste @@ -0,0 +1,244 @@ +Verona +conditionals +(top + { + 668 = class} + (class + { + None0 = class + None1 = class + None2 = class + None3 = class + None4 = class + include 668} + (ident 3:668) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (use + (type + (ident 3:std) + (doublecolon) + (ident 7:builtin))) + (class + { + test = function} + (ident 5:None0) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None0)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None0)) + (dontcare))) + (type + (ident 5:None0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None1) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None1)) + (block + (expr + (ident 5:None1)))) + (param + (ident 1:y) + (type + (ident 5:None1)) + (dontcare))) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None2) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None2)) + (block + (expr + (ident 5:None2))))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None3) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3)))) + (param + (ident 1:y) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3))))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None4) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param + z = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4)))) + (param + (ident 1:y) + (type + (ident 5:None4)) + (dontcare)) + (param + (ident 1:z) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4))))) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x)))))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/05_lambda.trieste b/testsuite/verona_nostdlib/issues/668/668_out/05_lambda.trieste new file mode 100644 index 000000000..a92936438 --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/05_lambda.trieste @@ -0,0 +1,244 @@ +Verona +lambda +(top + { + 668 = class} + (class + { + None0 = class + None1 = class + None2 = class + None3 = class + None4 = class + include 668} + (ident 3:668) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (use + (type + (ident 3:std) + (doublecolon) + (ident 7:builtin))) + (class + { + test = function} + (ident 5:None0) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None0)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None0)) + (dontcare))) + (type + (ident 5:None0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None1) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None1)) + (block + (expr + (ident 5:None1)))) + (param + (ident 1:y) + (type + (ident 5:None1)) + (dontcare))) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None2) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None2)) + (block + (expr + (ident 5:None2))))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None3) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3)))) + (param + (ident 1:y) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3))))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))))) + (class + { + test = function} + (ident 5:None4) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param + z = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4)))) + (param + (ident 1:y) + (type + (ident 5:None4)) + (dontcare)) + (param + (ident 1:z) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4))))) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x)))))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/06_autocreate.trieste b/testsuite/verona_nostdlib/issues/668/668_out/06_autocreate.trieste new file mode 100644 index 000000000..d3a87c9e9 --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/06_autocreate.trieste @@ -0,0 +1,454 @@ +Verona +autocreate +(top + { + 668 = class} + (class + { + None0 = class + None1 = class + None2 = class + None3 = class + None4 = class + create = function + new = function + include 668} + (ident 3:668) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (use + (type + (ident 3:std) + (doublecolon) + (ident 7:builtin))) + (class + { + create = function + new = function + test = function} + (ident 5:None0) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None0)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None0)) + (dontcare))) + (type + (ident 5:None0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = function} + (ident 5:None1) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None1)) + (block + (expr + (ident 5:None1)))) + (param + (ident 1:y) + (type + (ident 5:None1)) + (dontcare))) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = function} + (ident 5:None2) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2)) + (dontcare)) + (param + (ident 1:y) + (type + (ident 5:None2)) + (block + (expr + (ident 5:None2))))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$5)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = function} + (ident 5:None3) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3)))) + (param + (ident 1:y) + (type + (ident 5:None3)) + (block + (expr + (ident 5:None3))))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$6)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$7)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = function} + (ident 5:None4) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param + z = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4)))) + (param + (ident 1:y) + (type + (ident 5:None4)) + (dontcare)) + (param + (ident 1:z) + (type + (ident 5:None4)) + (block + (expr + (ident 5:None4))))) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$8)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$9)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 10:typevar$10)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 10:typevar$11)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/07_defaultargs.trieste b/testsuite/verona_nostdlib/issues/668/668_out/07_defaultargs.trieste new file mode 100644 index 000000000..9727978f7 --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/07_defaultargs.trieste @@ -0,0 +1,622 @@ +Verona +defaultargs +(top + { + 668 = class} + (class + { + None0 = class + None1 = class + None2 = class + None3 = class + None4 = class + create = function + new = function + include 668} + (ident 3:668) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (use + (type + (ident 3:std) + (doublecolon) + (ident 7:builtin))) + (class + { + create = function + new = function + test = function} + (ident 5:None0) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None0))) + (param + (ident 1:y) + (type + (ident 5:None0)))) + (type + (ident 5:None0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$0)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = + function + function} + (ident 5:None1) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = let} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (assign + (expr + (let + (ident 1:x))) + (expr + (ident 5:None1)))) + (expr + (Self) + (doublecolon) + (selector + (rhs) + (ident 4:test) + (int 1:0) + (typeargs)) + (expr + (reflet + (ident 1:x)))))) + (function + { + x = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None1))) + (error + (errormsg 70:Can't put a parameter with no default value after a parameter with one) + (param + (ident 1:y) + (type + (ident 5:None1)) + (dontcare)))) + (type + (ident 5:None1)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = + function + function} + (ident 5:None2) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = param + y = let} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2)))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (assign + (expr + (let + (ident 1:y))) + (expr + (ident 5:None2)))) + (expr + (Self) + (doublecolon) + (selector + (rhs) + (ident 4:test) + (int 1:0) + (typeargs)) + (tuple + (expr + (reflet + (ident 1:x))) + (expr + (reflet + (ident 1:y))))))) + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None2))) + (param + (ident 1:y) + (type + (ident 5:None2)))) + (type + (ident 5:None2)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$5)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = + function + function + function} + (ident 5:None3) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = let} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (assign + (expr + (let + (ident 1:x))) + (expr + (ident 5:None3)))) + (expr + (Self) + (doublecolon) + (selector + (rhs) + (ident 4:test) + (int 1:0) + (typeargs)) + (expr + (reflet + (ident 1:x)))))) + (function + { + x = param + y = let} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3)))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (assign + (expr + (let + (ident 1:y))) + (expr + (ident 5:None3)))) + (expr + (Self) + (doublecolon) + (selector + (rhs) + (ident 4:test) + (int 1:0) + (typeargs)) + (tuple + (expr + (reflet + (ident 1:x))) + (expr + (reflet + (ident 1:y))))))) + (function + { + x = param + y = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None3))) + (param + (ident 1:y) + (type + (ident 5:None3)))) + (type + (ident 5:None3)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$6)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$7)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (class + { + create = function + new = function + test = + function + function} + (ident 5:None4) + (typeparams) + (inherit + (dontcare)) + (typepred + (type + (typetrue))) + (classbody + (function + { + x = let} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (assign + (expr + (let + (ident 1:x))) + (expr + (ident 5:None4)))) + (expr + (Self) + (doublecolon) + (selector + (rhs) + (ident 4:test) + (int 1:0) + (typeargs)) + (expr + (reflet + (ident 1:x)))))) + (function + { + x = param} + (explicit) + (rhs) + (ident 4:test) + (typeparams) + (params + (param + (ident 1:x) + (type + (ident 5:None4))) + (error + (errormsg 70:Can't put a parameter with no default value after a parameter with one) + (param + (ident 1:y) + (type + (ident 5:None4)) + (dontcare)))) + (type + (ident 5:None4)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (reflet + (ident 1:x))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 9:typevar$8)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 9:typevar$9)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit)))))) + (function + {} + (explicit) + (rhs) + (ident 3:new) + (typeparams) + (params) + (type + (typevar 10:typevar$10)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (unit)))) + (function + {} + (implicit) + (rhs) + (ident 6:create) + (typeparams) + (params) + (type + (typevar 10:typevar$11)) + (dontcare) + (typepred + (type + (typetrue))) + (block + (expr + (new) + (unit))))))) diff --git a/testsuite/verona_nostdlib/issues/668/668_out/exit_code.txt b/testsuite/verona_nostdlib/issues/668/668_out/exit_code.txt new file mode 100644 index 000000000..56a6051ca --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/exit_code.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/testsuite/verona_nostdlib/issues/668/668_out/stderr.txt b/testsuite/verona_nostdlib/issues/668/668_out/stderr.txt new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/verona_nostdlib/issues/668/668_out/stdout.txt b/testsuite/verona_nostdlib/issues/668/668_out/stdout.txt new file mode 100644 index 000000000..5c480f407 --- /dev/null +++ b/testsuite/verona_nostdlib/issues/668/668_out/stdout.txt @@ -0,0 +1,14 @@ +Errors: +Can't put a parameter with no default value after a parameter with one +-- 668.verona:12:27 + test(x : None1 = None1, y : None1) : None1 + ~~~~~~~~~ + +---------------- +Can't put a parameter with no default value after a parameter with one +-- 668.verona:36:27 + test(x : None4 = None4, y : None4, z : None4 = None4) : None4 + ~~~~~~~~~ + +Pass defaultargs failed with 2 errors! +