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

better error/warning reporting when variable in pattern starts from a capital letter #4577

Open
andreykl opened this issue Oct 22, 2018 · 2 comments

Comments

@andreykl
Copy link

Example is from TTD book

data PowerSource = Pedal | Petrol | Electicity

data Vehicle : PowerSource -> Type where
  Unicyle : Vehicle Pedal
  Bicycle : Vehicle Pedal
  Motocycle : (fuel : Nat) -> Vehicle Petrol
  Car : (fuel : Nat) -> Vehicle Petrol
  Bus : (fuel : Nat) -> Vehicle Petrol
  Tram : Vehicle Electicity
  ElectricCar : Vehicle Electicity

total
wheels : Vehicle power -> Int
wheels Unicyle = 1
wheels Bicycle = 2
wheels Motocycle = 2
wheels (Car fuel) = 4
wheels (Bus fuel) = 4

Idris says wheels is total, but not all cases are checked.
It is possible that order of cases has the influence, but i'm not sure.
It is possible related with #1917

@esmolanka
Copy link

The Motocycle pattern in wheels function is missing an argument, therefore it was parsed as a variable that basically captures everything except the cases Unicycle and Bicycle. So the function is indeed total. You can have a look on what was in fact parsed with :def wheels in REPL.

Parsing is confusing and probably have to be somehow fixed in this case (by throwing an error or a warning), but totality checker is correct.

@andreykl
Copy link
Author

andreykl commented Dec 9, 2018

Thank you for your comment. Indeed.

@andreykl andreykl changed the title simple case for totality checker works wrong better error/warning reporting when variable in patern starts from a capital letter Dec 9, 2018
@andreykl andreykl changed the title better error/warning reporting when variable in patern starts from a capital letter better error/warning reporting when variable in pattern starts from a capital letter Dec 9, 2018
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