russplaysguitar / navel

Working towards a linter for cfscript
MIT License
2 stars 0 forks source link

ArraySet(array, start_pos, end_pos, value) #9

Open russplaysguitar opened 11 years ago

russplaysguitar commented 11 years ago

This should cause a lint warning if the start_pos and end_pos are the same, since that offers no advantage over traditional array usage (myArray[index] = 'value').

atuttle commented 11 years ago

Should also fail if start_pos > end_pos

russplaysguitar commented 11 years ago

@atuttle does that compile on either CF10 or Railo4?

atuttle commented 11 years ago

On ACF10 it does compile, but it also throws a runtime error.

<cfset foo = [1,2,3,4,5,6,7,8,9,10] />

If there's a compilation error, this text won't be seen.
If it's a runtime error, you should see it... I think?

<cfdump var="#foo#" />
<cfflush />

<cfset arraySet( foo, 4, 2, 0 ) />
<cfdump var="#foo#" />

russplaysguitar commented 11 years ago

Thanks for the follow up. On one issue (not sure which), there was discussion about not writing lint rules for things which throw errors. I've opened #37 to help clarify that. I think that the rule you proposed falls under that general category?

atuttle commented 11 years ago

Yeah, agreed.