tokiwa-software / fuzion

The Fuzion Language Implementation
https://fuzion-lang.dev
GNU General Public License v3.0
47 stars 11 forks source link

AoC issue: confusing error at `<built-in>` position #2382

Closed fridis closed 4 months ago

fridis commented 10 months ago

This

dec16_part1 is

  input := (io.stdin.with ()->io.buffered.read_lines).val.filter !=""
                                                     .map (.as_codepoints)
  area := array2 String input.count input[0].count i,j->input[i][j]

  part1 =>
    lm : mutate.
    lm.go ()->
      visited := (lm.array u8).type.new lm area.length 0
      r => 1
      l => 2
      u => 4
      d => 8
      ix(x,y) => y+x*area.length1
      trace(x,y,w i32) unit =>
        if ((x ∈ area.indices1) &&
            (y ∈ area.indices2) &&
            visited[ix x y] & d = 0) then
          visited[ix x y] = visited[ix x y] | d
          c := area[y,x]
      trace 0 0 r
      (visited.filter !=0).count

  say "part1 $part1"

refers to position <built-in> in the error

 > ~/fuzion/clean/fuzion/build/bin/fz -XmaxErrors=1 part1_error_at_pos_built-in.fz 

/home/fridi/fuzion/advent_of_code/fuzion_aoc/2023/16/part1_error_at_pos_built-in.fz:18:33: error 1: Incompatible types in branches of if expression
            (y ∈ area.indices2) &&
--------------------------------^^
Incompatible result types in different branches:
block returns value of type 'u8' at /home/fridi/fuzion/advent_of_code/fuzion_aoc/2023/16/part1_error_at_pos_built-in.fz:19:20:
            visited[ix x y] & d = 0) then
-------------------^
block returns value of type 'bool' at <built-in>:

<built-in>: warning 1: Maximum error count reached, terminating.
Maximum error count is 1.
Change this via property 'fuzion.maxErrorCount' or command line option '-XmaxErrors'.

one error and one warning.
michaellilltokiwa commented 4 months ago

closing this since now multiple errors due to change of stdlib but none are at position