Skip to content


Deprecate index()'s false return value #1127

nex3 opened this Issue · 5 comments

2 participants


79bad1f changed index() from returning false when not finding an element to returning null. As discussed in #832, we didn't think this necessitated a deprecation process since we expected users to be writing @if index(...). However, it seems that at least Foundation explicitly checks against false.

Rather than returning null immediately, we'll need to add a DeprecatedFalse value that complains if it's used in a way that is incompatible with the future null class.

@nex3 nex3 added this to the 3.3 milestone
@nex3 nex3 closed this

I've used a bit of "x == false" stuff in some cases where I care only about if something doesn't exist in a list.

Given we can't (or shouldn't) do x == false, and x == null also throws a warning, what should we do? I can only really think of checking for a "positive" value, and then immediately following it with an @else. But that seems kludgy.


Why can't you write @if not x?


You can - perfect! Thanks :) The warning from the compiler only suggested using @if x, hence why I was trying to figure a way around it.

Perhaps rather than throwing For example, instead of "@if index(...) == false", just write
"@if index(...)".
it could suggest @if not index(...) instead if that makes sense? (That message was from the Sass compiler in CodeKit 2).


It's tough to get enough contextual information to figure out the perfect error message, unfortunately :-/.


Actually, that error should just always say @if not index(...). I'll fix that.

@jvah jvah added a commit to jvah/viewports that referenced this issue
@jvah jvah Fix the index function use to work with new Sass versions.
On failure index returns now null instead of false, but viewports always
compares to false. This is easy to fix by taking a logical not of the resulting
value. For more information see sass/sass#1127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.