Skip to content
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

Pass SpecsValueTypeDerive incorrectly reports path for enum key #1137

Open
Mingun opened this issue Oct 5, 2024 · 0 comments
Open

Pass SpecsValueTypeDerive incorrectly reports path for enum key #1137

Mingun opened this issue Oct 5, 2024 · 0 comments

Comments

@Mingun
Copy link

Mingun commented Oct 5, 2024

Example of the current error:

# enum_unknown_inst_value.ksy: /instances/should_fail/enum:
# 	error: unable to find enum 'animal', searching from enum_unknown_inst_value
#
meta:
  id: enum_unknown_inst_value
instances:
  should_fail:
    value: 1
    enum: animal
[info] - enum_unknown_inst_value *** FAILED ***
[info]   [enum_unknown_inst_value.ksy: /instances/should_fail/value:
[info]          error: unable to find enum 'animal', searching from enum_unknown_inst_value
[info]   ]
[info]     did not equal
[info]   [enum_unknown_inst_value.ksy: /instances/should_fail/enum:
[info]          error: unable to find enum 'animal', searching from enum_unknown_inst_value
[info]   ] (SimpleMatchers.scala:34)

(error reported at path .../value instead of the correct path .../enum)

This error is generated by pass SpecsValueTypeDerive which calculates the type of value instance (i. e. expression in the value field). The reason, why enum key influences this pass is because handling of this key implemented as artificial change of the value expression by wrapping it by the Ast.expr.EnumById node.

Then TypeDetector tries to calculate type of this node using ClassTypeProvider.resolveEnum which throws an instance of ExpressionError due to unknown enum. When this exception is caught, it is reported as error in value field.

Possible solution would to not use the Ast.expr.EnumById node, but handle convertion to enum somehow else. Another way is to throw different error when processing Ast.expr.EnumById or somehow else distinguish between throwned errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants