@@ -184,6 +184,24 @@ scalarOutputTypes <- list(decide = 'logical',
184184# # and it will set the size expressions for A and for itself to 1.
185185expressionSymbolTypeReplacements <- c(' symbolNimbleListGenerator' , ' symbolNimbleList' , ' symbolNimbleFunction' , ' symbolMemberFunction' )
186186
187+ checkNameConflict <- function (nm ) {
188+ if (! exists(nm , nimbleUserNamespace $ .checkedNames )) {
189+ nimbleUserNamespace $ .checkedNames [[nm ]] <- 1
190+ # # Handle replacements such as `gamma` -> `gammafn`.
191+ if (nm %in% specificCallReplacements ) {
192+ nm <- names(specificCallReplacements )[which(nm == specificCallReplacements )]
193+ } else if (nm %in% nimKeyWords )
194+ nm <- names(nimKeyWords )[which(nm == nimKeyWords )]
195+ for (i in seq_along(nm )) { # `lgammafn` will give back two items, not one.
196+ objs <- sapply(nm [i ], function (x ) getAnywhere(x )$ objs )
197+ if (any(sapply(objs , is.rcf )))
198+ stop(" The name of the nimbleFunction `" , nm [i ], " ` conflicts with a function in the NIMBLE language (DSL); please use a different name" )
199+ }
200+ }
201+ }
202+
203+
204+
187205exprClasses_setSizes <- function (code , symTab , typeEnv ) { # # input code is exprClass
188206 # # name:
189207 if (code $ isName ) {
@@ -263,17 +281,7 @@ exprClasses_setSizes <- function(code, symTab, typeEnv) { ## input code is exprC
263281 }
264282 sizeCall <- sizeCalls [[code $ name ]]
265283 if (! is.null(sizeCall )) {
266- nm <- code $ name
267- # # Handle replacements such as `gamma` -> `gammafn`.
268- if (nm %in% specificCallReplacements ) {
269- nm <- names(specificCallReplacements )[which(nm == specificCallReplacements )]
270- } else if (nm %in% nimKeyWords )
271- nm <- names(nimKeyWords )[which(nm == nimKeyWords )]
272- for (i in seq_along(nm )) { # `lgammafn` will give back two items, not one.
273- objs <- sapply(nm [i ], function (x ) getAnywhere(x )$ objs )
274- if (any(sapply(objs , is.rcf )))
275- stop(" The name of the nimbleFunction `" , nm [i ], " ` conflicts with a function in the NIMBLE language (DSL); please use a different name" )
276- }
284+ checkNameConflict(code $ name )
277285 if (.nimbleOptions $ debugSizeProcessing ) {
278286 browser()
279287 eval(
0 commit comments