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

IHP codegen does not enforce capitalised View names #1950

Closed
liammcdermott opened this issue Apr 18, 2024 · 3 comments · Fixed by #2004
Closed

IHP codegen does not enforce capitalised View names #1950

liammcdermott opened this issue Apr 18, 2024 · 3 comments · Fixed by #2004

Comments

@liammcdermott
Copy link
Contributor

liammcdermott commented Apr 18, 2024

The steps I took, as an IHP beginner, just working with the web console:

  1. Created a table named users, using CodeGen
  2. Clicked CodeGen in the console, then Controller
  3. Entered users in the Controller name text box (notice the console corrects usersUsers so it's capitalised)
  4. This all seemed to work, so I went to CodeGen again, and selected Users from the drop-down. I was unsure what it meant precisely to create a View in this context, so in the View name text box I entered test.
  5. Clicked Preview then Generate

The CodeGen failed to generate valid Haskell code (since type and module names cannot be lowercase). The attached screenshot shows the Preview step, including the invalid code.

image

@liammcdermott
Copy link
Contributor Author

What I would expect to happen: IHP console should auto-capitalise the contents of View name, like it does when creating a Controller.

Also, I successfully reproduced this bug on master (love the new console gui when you run ./start. So slick!)

@mpscholten
Copy link
Member

Thanks, good catch 👍

Looks like the error is here: https://github.com/digitallyinduced/ihp/blob/master/IHP/IDE/CodeGen/ViewGenerator.hs#L83C24-L83C38

The {$nameWithSuffix} will always produce something like data X = {X} which is always invalid haskell. I guess it's just a typo and should be ${nameWithSuffix}

@liammcdermott
Copy link
Contributor Author

Thanks for the reply! Seems like a good beginner issue, so I'd like to have a go at fixing it.

Aside: it took me ~10 minutes of re-reading your last comment to see the difference between {$nameWithSuffix} and ${nameWithSuffix}, so I'm not surprised this issue came up!

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

Successfully merging a pull request may close this issue.

2 participants