fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

ast/Loop: `booleanAsImplicitResult` sometimes adds false even if false is already last expression in block

Open michaellilltokiwa opened this issue 1 year ago • 2 comments

e.g.:

private #loop0else1 bool : Any is Routine
  set #result := {
    say ("".infix + ({
      box(a)
    }).infix + box(" ").infix + ({
      box(#loop0else2.this.#^#loop0.#loop0else2.ix1)
    }).infix + box(" ").infix + ({
      box(#loop0else2.this.#^#loop0.#loop0else2.ix2)
    }).infix + "")
    false
    false
  }

michaellilltokiwa avatar Apr 22 '24 12:04 michaellilltokiwa

do you have an example fuzion code snippet for this?

maxteufel avatar May 15 '24 11:05 maxteufel

@maxteufel That would have been good to add in the first place. ;-) Thanks for pointing this out:


  for i in 1..2
  do
  until i > 3
  else
    false
{
  private #loop0else0 ***not yet known*** : Any is Routine
  {
    false
    false
  }
  private #loop0list0 ***not yet known*** is Field
  
  match #loop0list0
  #loop0list0cons Cons => {
    private i ***not yet known*** : Any is Field
    
    private #loop0(private i ***not yet known*** is Field
    , private #loop0list0arg ***not yet known*** is Field
    ) ***not yet known*** : Any is Routine
    {
      if i.infix > 3
        true
      else
        private #loop0else2 ***not yet known*** : Any is Routine
        {
          false
          false
        }
        match #loop0list0arg
        #loop0list0cons Cons => {
          private i ***not yet known*** : Any is Field
          
          #loop0 i #loop0list0cons.tail
        }
        #loop0list0nil nil => {
          #loop0else2
        }
        
      
    }
    #loop0 i #loop0list0cons.tail
  }
  #loop0list0nil nil => {
    #loop0else0
  }
  
}

michaellilltokiwa avatar May 15 '24 12:05 michaellilltokiwa