Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ion ion
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 84
    • Issues 84
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • redox-os
  • ionion
  • Issues
  • #994
Closed
Open
Created Dec 25, 2020 by matu3ba@matu3baMaintainer

Scopes: can not change variables in function from matches, conditionals or loops

bug: values in same function scope are not writable from matches, conditionals or loops. Additionally, one can not write into variables of higher scope. We need to clarify the syntax for this.

expect: It should be possible to write values in functions.

code: input

let x = 4
let y = 0
let z = 0
let a = 4
fn demo
  if test 1 == 1
    let x += 1
  end
  echo "x:" $x
  if test $x != 5
    echo "x broken"
  end

  for i in {0..=4}
    let z += 1
  end
  echo "z:" $z
  if test $z != 5
    echo "z broken"
  end

  match $a
    case 4; let a += 1
    case _; echo "FAIL"
  end
  echo "a:" $a
  if test $a != 5
    echo "a broken"
  end
  #echo $y
  #while test $y -lt  5
  #  let y += 1    # BROKEN: does not update y
  #  #echo $y
  #end
  #echo "y:" $y
  #if test $y != 5
  #  echo "y broken"
  #end
end
demo
echo $x
echo $y
echo $z
echo $a

actual: output

x: 4
x broken
z: 0
z broken
a: 4
a broken
4
0
0
4

expect: output

x: 5
y: 5
z: 5
a: 5
5
5
5
5

version: e033ca1c

interaction: none

Edited Dec 27, 2020 by matu3ba
Assignee
Assign to
Time tracking