@@ -656,17 +656,23 @@ toReport source err =
656 Report.toCodeSnippet source region Nothing $
656 Report.toCodeSnippet source region Nothing $
657 case names of
657 case names of
660+ makeTheory question details =
661+ H.fillSep $ map (H.dullyellow . H.text) (words question) ++ map H.text (words details)
660 H.reflow $
664 H.reflow $
661− "The `" <> N.toString name <> "` value has a direct use of `" <> N.toString name <> "` in its definition."
665+ "The `" <> N.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
663− -- TODO see if shadowing rules out mutation attempts
665− [ H.reflow $
668+ [ makeTheory "Are you are trying to mutate a variable?" $
666− "To know what `" <> N.toString name
669+ "Elm does not have mutation, so when I see " ++ N.toString name
670+ ++ " defined in terms of " ++ N.toString name
671+ ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
672+ , makeTheory "Maybe you DO want a recursive value?" $
667− <> "` is, I need to know what `" <> N.toString name
673+ "To define " ++ N.toString name ++ " we need to know what " ++ N.toString name
668− <> "` is. Let me recursively figure that out. Hmm, I need to know what `"
674+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ N.toString name
669− <> N.toString name <> "` is..."
675+ ++ " is, so let’s expand it... This will keep going infinitely!"
670 , H.link "Hint"
676 , H.link "Hint"
671 "The root problem is often a typo in some variable name, but I recommend reading"
677 "The root problem is often a typo in some variable name, but I recommend reading"
672 "bad-recursion"
678 "bad-recursion"
@@ -724,6 +730,7 @@ toReport source err =
724 \ the `point.x` syntax to access them."
730 \ the `point.x` syntax to access them."
726 , H.link "Note" "Read" "tuples"
732 , H.link "Note" "Read" "tuples"
727 "for more comprehensive advice on working with large chunks of data in Elm."
734 "for more comprehensive advice on working with large chunks of data in Elm."