Skip to content

Inconsistent array assignments #69

@adudek

Description

@adudek

There is a problem when trying to assign array by value to any variable after initialization. I prepared code sample to demonstrate my issue. To my knowledge every case should work exactly the same. What am I missing here?

#!/usr/bin/env bash

source "$( cd "${BASH_SOURCE[0]%/*}" && pwd )/lib/oo-bootstrap.sh"

import util/log
import util/class

class:MyIssue() {
  public string someMessage
  public array someMessageLines

  MyIssue.someStuff() {
    array someMessageLines="$(this someMessage toArray)"
    $var:someMessageLines
    if [[ $($var:someMessageLines length) != 0 ]]; then echo 'This stuff worked '; fi
  }
  MyIssue.someStufff() {
    array someMessageLines
    $var:someMessageLines="$(this someMessage toArray)"
    $var:someMessageLines
    if [[ $($var:someMessageLines length) != 0 ]]; then echo 'This stufff worked '; fi
  }
  MyIssue.someStuffff() {
    this someMessageLines="$(this someMessage toArray)"
    this someMessageLines
    if [[ $(this someMessageLines length) != 0 ]]; then echo 'This stuffff worked '; fi
  }
} 
Type::Initialize MyIssue

MyIssue my
$var:my someMessage = 'automatic
error
handling
with
exceptions
'

$var:my someStuff
echo '----------------'
$var:my someStufff
echo '----------------'
$var:my someStuffff

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions