Boo
  1. Boo
  2. BOO-501

slice duck typed arrays and lists

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.6
    • Fix Version/s: 0.7
    • Component/s: Runtime (Boo.Lang)
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      runtimeservices.getslice can't handle simple slicing of arrays or lists (when there is no defaultmember attribute).

      o as object //or duck if not in -ducky mode

      o = [1, 2, 3]
      print o[2]

      o = (4, 5, 6)
      print o[2]

      The patch isn't pretty because of tortoisesvn, but one way to fix this is to add this to getslice:
      if (target is IList && args.Length == 1 && args[0] is int)

      { return ((IList)target)[(int)args[0]]; }

        Activity

        Hide
        Doug H added a comment -

        This version of the patch adds index normalization:
        x as duck
        x = (1,2,3)
        print x[-1]

        Show
        Doug H added a comment - This version of the patch adds index normalization: x as duck x = (1,2,3) print x [-1]
        Hide
        Rodrigo B. de Oliveira added a comment -

        Applied with a minor change. Thanks!

        Show
        Rodrigo B. de Oliveira added a comment - Applied with a minor change. Thanks!

          People

          • Assignee:
            Doug H
            Reporter:
            Doug H
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: