on master help sign in
Put special docs for (%) operator
commit00c3a03cb8946d9ac3fb33a5670092311b5722aa authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 29 Mar 2018, 22:39 (9 years ago) parentc2253e5
1 file changed+19
compiler/src/Reporting/Error/Canonicalize.hs+19
compiler/src/Reporting/Error/Canonicalize.hs+19
@@ -467,6 +467,25 @@ toReport source err =
467467 "Switch to (^) for exponentiation. Or switch to (*) for multiplication."
468468 )
469469
470+ else if op == "%" then
471+ Report.Report "UNKNOWN OPERATOR" region [] $
472+ Report.toCodeSnippet source region Nothing
473+ (
474+ H.reflow $
475+ "Elm does not use (%) as the remainder operator:"
476+ ,
477+ H.stack
478+ [ H.reflow $
479+ "If you want the behavior of (%) like in JavaScript, switch to:\
480+ \ <https://package.elm-lang.org/packages/elm-lang/core/latest/Basics#remainderBy>"
481+ , H.reflow $
482+ "If you want modular arithmatic like in math, switch to:\
483+ \ <https://package.elm-lang.org/packages/elm-lang/core/latest/Basics#modBy>"
484+ , H.reflow $
485+ "The difference is how things work when negative numbers are involved."
486+ ]
487+ )
488+
470489 else
471490 let
472491 suggestions =