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

Feature Request: Compiler Warning Messages #1127

Open
Durbatuluk1701 opened this issue Jan 30, 2025 · 2 comments
Open

Feature Request: Compiler Warning Messages #1127

Durbatuluk1701 opened this issue Jan 30, 2025 · 2 comments

Comments

@Durbatuluk1701
Copy link

Durbatuluk1701 commented Jan 30, 2025

It would be a nice feature of the CakeML compiler for it to provide warning messages during compilation of possibly unintended behaviors.
 
Example:

fun is_upper_X str =
  let 
    val uppX = "X" 
    val lowX = "x" 
  in
    case str of
      uppX => True
    | lowX => False
  end
    
val () =
  let 
    val _ = TextIO.print (Bool.toString (is_upper_X "X"))
    val _ = TextIO.print "\n"
    val _ = TextIO.print (Bool.toString (is_upper_X "x"))
    val _ = TextIO.print "\n"
  in
    ()
  end

Running it will return

True
True (* Possibly unexpected behavior *)

I believe it would be beneficial for the compiler to give the user a warning such as Pattern "lowX" is redundant in this clause.

@myreen
Copy link
Contributor

myreen commented Jan 30, 2025

I agree that such warning messages are desirable.

However, the CakeML compiler doesn't really have a facility for generating warnings in general at the moment. I think this issue should be generalised to be about making the CakeML compiler generate warning messages and the example above could be one such warning message.

@Durbatuluk1701
Copy link
Author

That does seem like a good generalization, I can change the issue title and maybe add more information.

@Durbatuluk1701 Durbatuluk1701 changed the title Feature Request: Redundant Branch Detection Feature Request: Compiler Warning Messages Jan 31, 2025
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

2 participants