Skip to content

Commit 50fb02e

Browse files
committed
Allow traverse function implementation to return multiple errors
1 parent 34178f3 commit 50fb02e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/Compiler/Canonicalize/Module.elm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ canonicalizeBinop (A.At _ (Src.Infix op associativity precedence func)) =
8585
--
8686
-- 1. Detect cycles using ALL dependencies => needed for type inference
8787
-- 2. Detect cycles using DIRECT dependencies => nonterminating recursion
88+
--
8889

8990

9091
canonicalizeValues : SyntaxVersion -> Env.Env -> List (A.Located Src.Value) -> MResult i (List W.Warning) Can.Decls

src/Compiler/Reporting/Result.elm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,29 @@ bind callback (RResult ka) =
161161

162162
traverse : (a -> RResult i w x b) -> List a -> RResult i w x (List b)
163163
traverse func list =
164-
loop (traverseHelp func) ( list, [] )
164+
List.foldr
165+
(\(RResult kv) (RResult acc) ->
166+
RResult <|
167+
\i w ->
168+
case acc i w of
169+
ROk i1 w1 accList ->
170+
case kv i1 w1 of
171+
ROk i2 w2 value ->
172+
ROk i2 w2 (value :: accList)
173+
174+
RErr i2 w2 e2 ->
175+
RErr i2 w2 e2
176+
177+
RErr i1 w1 e1 ->
178+
case kv i1 w1 of
179+
ROk i2 w2 _ ->
180+
RErr i2 w2 e1
181+
182+
RErr i2 w2 e2 ->
183+
RErr i2 w2 (OneOrMore.more e1 e2)
184+
)
185+
(pure [])
186+
(List.map func list)
165187

166188

167189
traverseHelp : (a -> RResult i w e b) -> ( List a, List b ) -> RResult i w e (Step ( List a, List b ) (List b))

tests/backwards-compatibility.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe("backwards compatibility", () => {
160160
});
161161

162162
describe("tuples", () => {
163-
test.skip("fails on 3+ tuples on elm files", () => {
163+
test("fails on 3+ tuples on elm files", () => {
164164
const elmOutput = `${tmpDir}/guida-test-elm-tuple-n-${process.pid}.json`;
165165
const guidaOutput = `${tmpDir}/guida-test-guida-tuple-n-${process.pid}.json`;
166166

0 commit comments

Comments
 (0)