Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
ion
ion
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 95
    • Issues 95
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 3
    • Merge Requests 3
  • Operations
    • Operations
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • redox-os
  • ionion
  • Issues
  • #994

Closed
Open
Opened Dec 25, 2020 by matu3ba@matu3baDeveloper

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
Ion Shell v1.0.0beta
Milestone
Ion Shell v1.0.0beta
Assign milestone
Time tracking
None
Due date
None
Reference: redox-os/ion#994