Skip to content

Commit

Permalink
Merge pull request #253 from mrc-ide/i252-no-named-args
Browse files Browse the repository at this point in the history
Disallow named args in calls
  • Loading branch information
weshinsley authored Jan 4, 2022
2 parents 713ee8e + 84f7b13 commit bffbf98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
5 changes: 5 additions & 0 deletions R/ir_parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-parse2-general.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

0 comments on commit bffbf98

Please sign in to comment.