SpacemanDMM
SpacemanDMM copied to clipboard
ast's VALID_FILTER_FLAGS doesn't support non-constants
see:
filter(type="color", space=pick(FILTER_COLOR_HSV, FILTER_COLOR_RGB), color="#fff")
filter(type="layer", render_source = foo.render_target, flags=pick(FILTER_OVERLAY, FILTER_UNDERLAY))
error for first one:
filter(type="color") called with invalid 'space' value 'Pick([(None, Base { unary: [], term: Spanned { location: Location { file: FileId(135), line: 270, column: 57 }, elem: Ident("FILTER_COLOR_HSV") }, follow: [] }), (None, Base { unary: [], term: Spanned { location: Location { file: FileId(135), line: 270, column: 75 }, elem: Ident("FILTER_COLOR_RGB") }, follow: [] })])'
@spookydonut
The only sensible thing to do here is to emit no diagnostic (or maybe just an Info?) if the expression is anything other than a series of idents or numbers OR'd together.
The things we DO want to forbid are:
-
filter(type="color", space=FILTER_COLOR_RGB|FILTER_COLOR_HSV)
- using|
for a non-bitflags parameter -
filter(type="color", space=0)
- using 0 for a non-bitflags parameter -
filter(type="outline", flags=1)
- using a magic number instead of a named constant -
filter(type="outline", flags=WAVE_SIDEWAYS)
- using a flag that belongs to a different filter