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

Getting rid of warnings in PrettyPrinter.hs #189

Merged
merged 1 commit into from
Jul 24, 2015
Merged

Getting rid of warnings in PrettyPrinter.hs #189

merged 1 commit into from
Jul 24, 2015

Conversation

EliasC
Copy link
Contributor

@EliasC EliasC commented Jul 21, 2015

This commit gets rid of the warnings given by missing cases in the
pretty-printer. It had just been bugging me for ages.

@albertnetymk
Copy link
Contributor

On the master branch, I don't get any warning for clean build.

@EliasC
Copy link
Contributor Author

EliasC commented Jul 21, 2015

Here is what I get from a clean build on master

bash-3.2$ make
...
[ 9 of 36] Compiling AST.PrettyPrinter ( src/ir/AST/PrettyPrinter.hs, dist/build/encorec/encorec-tmp/AST/PrettyPrinter.o )

src/ir/AST/PrettyPrinter.hs:66:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘ppQName’: Patterns not matched: []

src/ir/AST/PrettyPrinter.hs:85:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘ppImportDecl’:
        Patterns not matched: PulledImport _ _ _ _

src/ir/AST/PrettyPrinter.hs:141:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘ppExpr’:
        Patterns not matched:
            Foreach _ _ _ _
            FinishAsync _ _

src/ir/AST/PrettyPrinter.hs:209:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘ppUnary’:
        Patterns not matched:
            AND
            OR
            Identifiers.LT
            Identifiers.GT
            ...

src/ir/AST/PrettyPrinter.hs:212:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘ppBinop’: Patterns not matched: NOT
...

@albertnetymk
Copy link
Contributor

This is so odd. BTW, the branching you are working on, https://github.com/EliasC/encore/tree/fix/ppWarnings, is 6 commits behind encore/master.

@EliasC
Copy link
Contributor Author

EliasC commented Jul 21, 2015

Thanks! I had forgotten to update my own master branch! In this branch I don't see the warnings either, which is actually weird. For example there should be a warning for the following function:

ppQName :: QName -> Doc
ppQName [a] = ppName a 
ppQName (a:as) = ppName a <+> text "." <+> ppQName as

Do you know if one of the latest commits disables any warnings?

Still, I think the refactoring in this PR makes sense. Let me know if you would like me to reword it.

@albertnetymk
Copy link
Contributor

The non-exhaustive thing in this particular file, if happens in runtime, it indicates a bug from the compiler developers. IOW, we know for sure it would not happen, so I disabled it, I think. For the refactoring you can create a PR now or you could attach this refactoring along with some other change. Either way makes sense.

@EliasC
Copy link
Contributor Author

EliasC commented Jul 21, 2015

I added the warning there so that you could get a warning at compile time instead of at runtime! The idea was that if you add something to the AST you should get warnings that help you find all the places you need to update. By disabling it we require that all programmers know how the whole compiler works. I would like to re-add the warning (and for future warnings to not be disabled unless there is a clear commit message highlighting and motivating why that warning should be disabled).

@albertnetymk
Copy link
Contributor

That's a fair argument. I failed to anticipate the evolving of the AST. Thanks.

@EliasC
Copy link
Contributor Author

EliasC commented Jul 21, 2015

@albertnetymk I added the warning after the fifth person came to me asking why their new addition to the AST didn't work properly :)

@albertnetymk
Copy link
Contributor

What?! I thought there are totally four (if I count myself) persons working on this. Besides, the runtime error should have occurred, shouldn't it?

@EliasC
Copy link
Contributor Author

EliasC commented Jul 21, 2015

(You, me, Kiko, Stephan, Tobias, Dave, plus a bunch of students)

Not literally the "fifth" person. I should have said "there were reoccurring errors stemming from people (including myself) forgetting to extend PrettyPrinter.hs, so I added the warning to help everyone out". If I recall correctly there was a catch-all case, so there were no runtime errors.

@@ -222,3 +230,4 @@ ppBinop Identifiers.MINUS = text "-"
ppBinop Identifiers.TIMES = text "*"
ppBinop Identifiers.DIV = text "/"
ppBinop Identifiers.MOD = text "%"
ppBinop op = error $ "Cannot pretty-print binary expression '" ++ show op ++ "'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would surpass any compiling warning, even if a new node is added, right?

@EliasC
Copy link
Contributor Author

EliasC commented Jul 21, 2015

That's a fair point. Fixed in the latest commit.

@albertnetymk
Copy link
Contributor

The intention of this PR is possibly changed, so you may want to rebase. There's support for git for trailing spaces, here. These are minor things; if you don't plan to do any future update, I think it's ready to be merged.

@EliasC
Copy link
Contributor Author

EliasC commented Jul 23, 2015

Pushed a last minor layout fix. I'm done with this PR now.

@albertnetymk
Copy link
Contributor

Do you think if it's good to do a rebase to squeeze/rename some of commits before merging?

@EliasC
Copy link
Contributor Author

EliasC commented Jul 24, 2015

Just realized I based the squash on an unmerged PR... Hold on...

This commit re-adds the warnings for missing cases in the
pretty-printer (and gets rid of some of the warnings that found its way
in while it was gone). The reason for this is to alert anyone adding new
AST nodes that the pretty-printer must also be updated.
@EliasC
Copy link
Contributor Author

EliasC commented Jul 24, 2015

There! Squashed, reworded and ready for merge.

kaeluka pushed a commit that referenced this pull request Jul 24, 2015
Getting rid of warnings in `PrettyPrinter.hs`
@kaeluka kaeluka merged commit 31623d5 into parapluu:master Jul 24, 2015
@EliasC EliasC deleted the fix/ppWarnings branch July 28, 2015 14:25
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 this pull request may close these issues.

3 participants