ChildsplayOSU / bogl

Haskell implementation of the BoGL language
https://bogl.engr.oregonstate.edu
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Enforces Lowercase Parameter Names #164

Closed montymxb closed 3 years ago

montymxb commented 3 years ago

Closes #163, a reported issue earlier today where a student encountered the following form of parsing bug:

game Ex

type Content = {X,O}

f : Context -> Bool
f(X) = if X == O then True else False

Pre-patch this generates no parse error, and returns 'False' every time as if it were a constant function. Looking into this I found that the same behavior was also present in function application (would generate a type error instead of a parse error) and the name binding associated with a let expression (which would succeed silently as well). These cases are detailed as:

-- bad let
let X = 5 in 5

...

-- bad func app generates a type error instead of a parse error, as no function should start like this
type Content = {X,O}
X(1)

This patch introduces a lookAhead lower on all three of these instances where a new name can be bound to the environment, and enforces a leading lowercase alpha character. Failing tests for all three instances were added and verified to be corrected post-patch. As a followup, I double checked declarations for functions and value eqs, but found these to be properly verified.

@alexgrejuc this should be ready to merge, but let me know if I missed any cases where a new name can be bound that needs to be cased properly and is not. I think I covered everything here however.