Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal compiler error: TypeError: a.charCodeAt is not a function #1446

Open
tuulam opened this issue Aug 16, 2024 · 23 comments
Open

Internal compiler error: TypeError: a.charCodeAt is not a function #1446

tuulam opened this issue Aug 16, 2024 · 23 comments

Comments

@tuulam
Copy link

tuulam commented Aug 16, 2024

This happened also a couple of days ago. Now I have the code that caused it:

lambda_true = 3
N = 5
set.seed(111111)
(y = rpois(N, lambda_true))
poisson_dat = list(y = y, N = N)
alpha = beta = 1
data {
	int<lower=0> N;
	array[N] int<lower=0> y;
}

parameters {
	real<lower=0> lambda;
}
model {
	lambda ~ lognormal(0,1);
	y ~ poisson(lambda);
}
fit2 <- stan('poisson_lognormal.stan', poisson_dat, iter = 20000, chains = 4)

The error message:
Error in stanc(file = file, model_code = model_code, model_name = model_name,  : 
  0
Internal compiler error:
TypeError: a.charCodeAt is not a function

Rstan 2.35.0.9000

This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.

I removed the package V8 but it didn't change the situation.

@andrjohns
Copy link
Contributor

And can you post the results of the same debugging steps from earlier (calling stanc on the model code as a string and then on the file)?

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

andrjohns commented Aug 16, 2024 via email

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

lambda_true = 3
N = 5
set.seed(111111)
(y = rpois(N, lambda_true))
poisson_dat = list(y = y, N = N)
alpha = beta = 1

fit2 <- stan('poisson_lognormal.stan', poisson_dat, iter = 20000, chains = 4)

The stan file is the following

data {
      int<lower=0> N;
      array[N] int<lower=0> y;
}

parameters {
      real<lower=0> lambda;
}
model {
      lambda ~ lognormal(0,1);
      y ~ poisson(lambda);
}


From: Andrew Johnson @.>
Sent: Friday, August 16, 2024 12:56 PM
To: stan-dev/stanc3 @.
>
Cc: tuulam @.>; Author @.>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)

Can you show the full R code that you used? Just so I can be running the same thing

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: tuulam @.>
Sent: Friday, August 16, 2024 12:55:04 PM
To: stan-dev/stanc3 @.
>
Cc: Andrew Johnson @.>; Comment @.>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)

Error in stanc(file = file, model_code = model_code, model_name = model_name, :
0
Internal compiler error:
TypeError: a.charCodeAt is not a function

This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.


From: Andrew Johnson @.>
Sent: Friday, August 16, 2024 12:44 PM
To: stan-dev/stanc3 @.
>
Cc: tuulam @.>; Author @.>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)

And can you post the results of the same debugging steps from earlier (calling stanc on the model code as a string and then on the file)?


Reply to this email directly, view it on GitHub#1446 (comment), or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALZZ4U23CPXHNZMIHWJSR6TZRXCY7AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGE4DONZQG4.
You are receiving this because you authored the thread.Message ID: @.***>


Reply to this email directly, view it on GitHub#1446 (comment), or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGTPCCBOTCXHVCCPBODHJJTZRXD7RAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDENZSGQ.
You are receiving this because you commented.Message ID: @.***>


Reply to this email directly, view it on GitHub#1446 (comment), or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALZZ4U35OX4475CSCSELQ7DZRXEFXAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDKNBVG4.
You are receiving this because you authored the thread.Message ID: @.***>

And can you do the same for running stanc on the model as a string? (The full R code and the results)

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

andrjohns commented Aug 16, 2024

I am not sure what I am supposed to do.

Like the following:

stancode <- "YOUR MODEL CODE"
rstan::stanc(model_code=stancode)

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

andrjohns commented Aug 16, 2024

If your model is:

data {
  int<lower=0> N;
  array[N] int<lower=0> y;
}

parameters {
  real<lower=0> lambda;
}
model {
  lambda ~ lognormal(0,1);
  y ~ poisson(lambda);
}

Then run:

stancode <- "
data {
  int<lower=0> N;
  array[N] int<lower=0> y;
}

parameters {
  real<lower=0> lambda;
}
model {
  lambda ~ lognormal(0,1);
  y ~ poisson(lambda);
}
"

rstan::stanc(model_code=stancode)

And post the R code you used and the result

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@WardBrian
Copy link
Member

Hi @tuulam -- your last reply seems to be blank. Could you send the output again?

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

That indicates no error, are you still getting the error with your Stan file?

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

Interesting!

Can you run:

cat("poisson_lognormal.stan", sep="\n")
rstan::stanc(file="poisson_lognormal.stan")

@andrjohns
Copy link
Contributor

cat("poisson_lognormal.stan", sep="\n")

Oops, that should be: readLines("poisson_lognormal.stan") instead

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

Hmm also no error there, and if you run:

rstan::stan("poisson_lognormal.stan", data = list(N=1, y=1))

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

Ah, try this instead:

rstan::stan("poisson_lognormal.stan", data = list(N=2, y=c(1, 2)))

@tuulam
Copy link
Author

tuulam commented Aug 16, 2024 via email

@andrjohns
Copy link
Contributor

So it looks like both parsing and sampling from your Stan model is working without issue. What R code are you running that is giving the error still?

@tuulam
Copy link
Author

tuulam commented Aug 17, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants