New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve NumberType | NumberArrayType ambiguity with a new SizeType #15818
Conversation
📦 Preview the website for this branch here: https://deploy-preview-15818--ol-site.netlify.app/. |
9a4f459
to
f356c9f
Compare
'circle-scale': ['get', 'iconSize', 'number[]'], | ||
'circle-scale': ['get', 'iconSize'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual achievement - no type hint needed any more!
This is now ready for review. |
@@ -485,6 +497,12 @@ function compile(expression, returnType, context) { | |||
return arrayToGlsl(/** @type {Array<number>} */ (expression.value)); | |||
} | |||
|
|||
if ((expression.type & SizeType) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since anything that includes the NumberType
is already handled above, isn’t this only testing that NumberArrayType
is included?
I’m only reviewing on a small device, so probably missing context, but it isn’t clear to me why we aren’t checking for more narrow types in all these if
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I must be missing something. I see NumberArrayType
is also checked right above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tschaub Looks like you're not missing anything, but that code is missing tests. Looking into it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SizeType
should be a distinct type, like ColorType
, instead of a broadened type. But I haven't been able to fully wrap my head around the types involved in the parsing and compilation phases to figure out how that works. So @tschaub, if you have an idea how that could be achieved, any help would be appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I think I figured it out, @tschaub. Before I commit, I'm adding more tests.
a57c160
to
e10117a
Compare
@tschaub Ready for review - tests added, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this, @ahocevar.
This pull request removes the only real-life need for type hints in
"get"
call expressions, which was needed due to an ambiguity betweenNumberType
andNumberArrayType
for-scale
style properties.With the new
SizeType
, it would also be possible to support styles like'icon-size': 24
instead of'icon-size': [24, 24]
, but I did not make this change here.