Make sure FunctionKind is determined in all entry points

There are a lot of entry points for a Roc program. They should probably
be all consolidated into one, but for now, when FunctionKind is needed,
determine it from the environment. This fixes EXPERIMENTAL_ROC_ERASE for
`roc test` etc.

Also print the location of a failure when `internal_error!` is called. I
think this should panic instead, and I thought it used to - does anyone
know if that changed?
This commit is contained in:
Ayaz Hafiz 2024-07-07 16:01:14 -05:00
parent 6869c9f2e1
commit 0e52a7e069
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
6 changed files with 31 additions and 25 deletions

View file

@ -6,3 +6,17 @@ pub enum FunctionKind {
/// Function values are erased, no kind is introduced.
Erased,
}
impl FunctionKind {
pub fn from_env() -> Self {
if cfg!(debug_assertions) {
if std::env::var("EXPERIMENTAL_ROC_ERASE").is_ok() {
FunctionKind::Erased
} else {
FunctionKind::LambdaSet
}
} else {
FunctionKind::LambdaSet
}
}
}