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

Crash on unnecessary underscore with case #724

Open
Namek opened this issue Jan 3, 2025 · 1 comment
Open

Crash on unnecessary underscore with case #724

Namek opened this issue Jan 3, 2025 · 1 comment
Labels
language Language feature

Comments

@Namek
Copy link
Contributor

Namek commented Jan 3, 2025

hi there, I've got a compiler crash with a case like this:

fun toggleTheme : Promise(Void) {
  let currentTheme = Dom.getAttribute(`document.documentElement`, "data-theme")

  let newTheme =
    case currentTheme {
      "light" => "dark"
      "dark" => "light"
      _ => "dark"
    }
}

Originally, I had a couple of guesses but... oh yeah it's about the underscore in the last case. A habit coming from other languages.

SCOPE!!!: Mint::Ast::Discard (Exception)
  from mint in 'raise<Exception>:NoReturn'
  from mint in 'raise<String>:NoReturn'
  from mint in 'Mint::Scope#build<(Mint::Ast::Node+ | Nil), Mint::Ast::CaseBranch>:(Mint::Ast::Node+ | Mint::Scope::Target | Nil)'
  from mint in 'Mint::Scope#build<Array(Mint::Ast::CaseBranch), Mint::Ast::Case>:(Mint::Ast::Node+ | Nil)'
  from mint in 'Mint::Scope#build<Mint::Ast::Node+, Mint::Ast::Node+>:(Mint::Ast::Node+ | Mint::Scope::Target | Nil)'
  from mint in 'Mint::Scope#build<Mint::Ast::Block, Mint::Ast::Function>:(Mint::Ast::Node+ | Nil)'
  from mint in 'Mint::Scope#build<Mint::Ast::Node+>:(Mint::Ast::Node+ | Mint::Scope::Target | Nil)'
  from mint in 'Mint::TypeChecker::Artifacts::new<Mint::Ast>:Mint::TypeChecker::Artifacts'
  from mint in 'Mint::Workspace#update<Array(String), Symbol>:(Set(Tuple(String, Time)) | Nil)'
  from mint in 'Mint::Watcher#scan<Symbol>:Set(Tuple(String, Time))'
  from mint in 'Mint::Workspace#reset:(Set(Tuple(String, Time)) | Nil)'
  from mint in 'Mint::Workspace::new:path:dot_env:check:include_tests:format:listener<String, String, Mint::Check, Bool, Bool, Proc((Mint::Error | Mint::TypeChecker), Nil)>:Mint::Workspace'
  from mint in 'Mint::Cli::Start#parse_and_run:Nil'
  from mint in 'Mint::Cli#parse_and_run:Nil'
  from mint in '__crystal_main'
  from mint in 'main'

I am not sure what should happen when someone puts underscore there. Should be disregarded (then introducing 2 ways of supporting the "else" case)? Or treated as a compile error?

@gdotdesign
Copy link
Member

This was fixed in 6e51502 with 0.20.1 but it didn't get into 0.21.0 🤦 I'll create a bug fix release for this soon.

@Sija Sija added the language Language feature label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Language feature
Development

No branches or pull requests

3 participants