Yes, looks like it's more convoluted. "vector" and "string" are lowercase tokens that can't be used for variable names for instance. Doing "float2 sTring;" is valid, but "sTring" can't be used as a type after that. Reusing names of already declared variables as typenames is universally disallowed, so that's good.
Hrm, I thought I tested redefining non-lower-case versions of those, but I must have done it wrong.
Anyway, this is still failing with the example I posted, as far as I can tell because hlsl_get_type's recursive call passes "false" rather than propagating the "case_insensitive" argument.
Also, from patch 1/3:
- for (i = 0; i < ARRAY_SIZE(names); ++i)
if (!ascii_strcasecmp(names[i], name)) return names[i];
Please put the "if" body on a new line, and use braces for multi-line bodies even if it's technically a single statement.
- if (case_insensitive && !scope->upper && (name = get_case_insensitive_typename(name)))
- {
if ((entry = rb_get(&scope->types, name)))
return RB_ENTRY_VALUE(entry, struct hlsl_type, scope_entry);
- }
It looks mildly wrong that this checks "scope->upper" but not "recursive". It works, because we never pass recursive == false but case_insensitive == true, but I think it'd be clearer just to move this below the recursive call or use "else" there.
@@ -4565,7 +4565,7 @@ type_no_void: } | KW_STRUCT TYPE_IDENTIFIER {
$$ = hlsl_get_type(ctx->cur_scope, $2, true);
$$ = hlsl_get_type(ctx->cur_scope, $2, true, false); if ($$->type != HLSL_CLASS_STRUCT) hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2); vkd3d_free($2);
This lacks tests (and also feels a little suspicious, mostly because it contradicts the lexer).