From 0f2551c45db189f751504403ac8aa384a7f69c42 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Mon, 20 Dec 2021 17:48:09 +0000 Subject: [PATCH 1/2] Disallow named args in calls --- R/ir_parse.R | 5 +++++ tests/testthat/test-parse2-general.R | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/R/ir_parse.R b/R/ir_parse.R index 7c0dd4c0..71c6e61d 100644 --- a/R/ir_parse.R +++ b/R/ir_parse.R @@ -1505,6 +1505,11 @@ ir_parse_expr_rhs_check_usage <- function(rhs, line, source) { } } } + + if (!is.null(names(x))) { + throw("Named argument calls not supported in odin") + } + lapply(as.list(x[-1L]), check_usage) } } diff --git a/tests/testthat/test-parse2-general.R b/tests/testthat/test-parse2-general.R index 4b292913..e46184ac 100644 --- a/tests/testthat/test-parse2-general.R +++ b/tests/testthat/test-parse2-general.R @@ -840,3 +840,14 @@ test_that("can't use C identifier", { }), "Reserved name 'int' for lhs") }) + + +test_that("Can't use named args", { + expect_error( + odin_parse({ + update(x) <- rbinom(1, prob = 0.5) + initial(x) <- 1 + }), + "Named argument calls not supported in odin", + fixed = TRUE) +}) From 84f7b13a3bf21aa1f976363693f376eecab8f714 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Mon, 20 Dec 2021 17:50:39 +0000 Subject: [PATCH 2/2] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index ea1608b9..138c8d11 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: odin Title: ODE Generation and Integration -Version: 1.3.1 +Version: 1.3.2 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Thibaut", "Jombart", role = "ctb"),