compass-mixins icon indicating copy to clipboard operation
compass-mixins copied to clipboard

Possible typo leading to error

Open waynetheisinger opened this issue 10 years ago • 5 comments

I'm getting:

{ [Error: bower_components/compass-mixins/lib/compass/functions/_lists.scss
  34:12  index out of bounds for `nth($list, $n)`]
  message: 'bower_components/compass-mixins/lib/compass/functions/_lists.scss\n  34:12  index out of bounds for `nth($list, $n)`',
  column: 12,
  line: 34,
  file: './bower_components/compass-mixins/lib/compass/functions/_lists.scss',
  status: 1,
  messageFormatted: '\u001b[4mbower_components/compass-mixins/lib/compass/functions/_lists.scss\u001b[24m\n\u001b[90m  34:12\u001b[39m  index out of bounds for `nth($list, $n)`',
  name: 'Error',
  stack: 'Error: bower_components/compass-mixins/lib/compass/functions/_lists.scss\n  34:12  index out of bounds for `nth($list, $n)`\n    at options.error (/var/www/mdcurrent_dev/.modman/mdv14/skin/frontend/mdthemes/mdresponsive/build/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:277:32)',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-sass' }

Changing

    @for $i from 2 through length($items) {
      $item: nth($items, $i);
      @if $item != null {
        $full: $full $item;
      }
    }

To

    @for $i from 1 through length($items) {
      $item: nth($items, $i);
      @if $item != null {
        $full: $full $item;
      }
    }

Fixes it... typo?

waynetheisinger avatar Sep 24 '15 12:09 waynetheisinger

actually, this is not just a typo, when I change to 1, I now get the first item in the list twice... column-rule: 1px 1px solid #eee; so you are intending to use 2, not sure why the first is repeated though and not sure how to stop the out of index error if I change to 2 -- I'm now reading up on sass systax in order to debug...

waynetheisinger avatar Sep 24 '15 15:09 waynetheisinger

This seems to do what I want

  @for $i from 1 through length($items) {
      @if $i != 1 {
        $item: nth($items, $i);
        @if $item != null {
          $full: $full $item;
        }
      }
    }

waynetheisinger avatar Sep 24 '15 15:09 waynetheisinger

I'm having the same issue with the latest version. The fix by @waynetheisinger works.

shadcn avatar Jun 17 '16 10:06 shadcn

I think this work around is red herring for the real issue. Sass lists are 1 indexed so nth($list, length($list)) is within bounds. This is not the case for 0 indexed arrays common in other languages.

xzyfer avatar Jun 17 '16 13:06 xzyfer

@xzyfer I'm using the fix by @waynetheisinger on a project temporarily. But I agree, we need to figure out where it's really coming from.

shadcn avatar Jun 17 '16 13:06 shadcn