Giter Club home page Giter Club logo

Comments (13)

erikd avatar erikd commented on June 7, 2024

For those of use who don't use stack, what GHC version is included in "LTS 7.14"?

Update: You also don't mention what version of alex. I fixed a number of issues like this about 3 months ago.

from alex.

simonmar avatar simonmar commented on June 7, 2024

I'm not a fan of -Wname-shadowing and I normally turn it off. What exactly does --pedantic do, and when do you encounter these errors? When building Alex itself, or something that uses Alex?

from alex.

pjljvandelaar avatar pjljvandelaar commented on June 7, 2024

LTS 7.14 uses GHC 8.0.1 and alex-3.1.7 (see https://www.stackage.org/lts-7.14)
pedantic: turn on all warnings and errors (in ghc and all other programs used to build)

I am building my own Name.x files.
Yet, their compilation uses some template files of Alex that cause the warning
(that is considered an error due to pedantic)!

Checking for name-shadowing can prevent unexpected behavior.
We once had an issue with a variable called map and the map function.

from alex.

erikd avatar erikd commented on June 7, 2024

@pjljvandelaar Alex is currently at version 3.2.1 and I think at least some of those warnings have been fixed.

@simonmar I got caught a couple of times in C code with name shadowing and started passing -Wshadow to gcc well over a decade ago. When took up Haskell I was very pleased to notice that the name shadowing warning is part of -Wall so I don't have to remember to set it. For things like the Alex template files, it would be a good idea for them to be as warning clean as possible so that the Alex user can turning on as many warnings as they feel comfortable with and see (hopefully) zero warnings from the template code.

from alex.

pjljvandelaar avatar pjljvandelaar commented on June 7, 2024

I agree with the fact that some warnings have been fixed (as was already mentioned in the first message)

I also agree with having the alex template files as warning clean as possible!
Solving name-shadowing is relatively easy.
We often just append the name with ' to make it unique.

from alex.

erikd avatar erikd commented on June 7, 2024

I found that the tests are currently building with -fno-warn-name-shadowing so that these warnings are not being triggered at during cabal test. Working on fixing that.

from alex.

simonmar avatar simonmar commented on June 7, 2024

I'm well aware that accidental shadowing can cause unexpected bugs. But deliberate shadowing can also be used to prevent bugs, which is why I personally prefer to leave the warning turned off. That and the fact that I often like to use id as a variable name :)

But I'm not against avoiding warnings in template code, by all means go ahead.

from alex.

PierreVDL avatar PierreVDL commented on June 7, 2024

@erikd In which version of alex will this bug be fixed?

from alex.

pjljvandelaar avatar pjljvandelaar commented on June 7, 2024

Problem keeps returning:

templates\wrappers.hs:448:25: warning: [-Wname-shadowing]
    This binding for `str' shadows the existing binding
      bound at templates\wrappers.hs:447:16

Please fix the template code !

from alex.

simonmar avatar simonmar commented on June 7, 2024

I'm not sure how sustainable this is, but I've fixed the shadowing warnings.

from alex.

pjljvandelaar avatar pjljvandelaar commented on June 7, 2024

You can enforce it by using the flags -Wall -Werror on your code
or
You can add tags for the Haskell compiler to your templates such that the compiler doesn't complain.

from alex.

pjljvandelaar avatar pjljvandelaar commented on June 7, 2024

Thanks!

from alex.

simonmar avatar simonmar commented on June 7, 2024

@pjljvandelaar I know about the flags :) Indeed the tests are run with -Wall -Werror, and I just removed -fno-warn-name-shadowing, so this won't break again.

The reason I say it isn't sustainable is that Alex appends some template code to the module, so there will inevitably be name clashes. There's no way I can pick a local name in the Alex template code that is guaranteed not to shadow anything in the user code. I've made the names unlikely to clash, but there's no guarantee.

from alex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.