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

Typestring parser crashes on some cases of shadowing #158

Open
cd1m0 opened this issue Oct 12, 2022 · 0 comments
Open

Typestring parser crashes on some cases of shadowing #158

cd1m0 opened this issue Oct 12, 2022 · 0 comments
Assignees
Labels
bug Something isn't working cac Issue discovered from running over the contract archive

Comments

@cd1m0
Copy link
Contributor

cd1m0 commented Oct 12, 2022

Given the following code:

contract Test {
    struct Test {
        uint x;
    }

    function main() public {
         this;
    }
}

The type string of this is contract Test. When trying to parse that however the typestring parser will fail with the following exception:

     Error: Couldn't find ContractDefinition Test
      at makeUserDefinedType (src/types/typeStrings/typeString_parser.ts:153:15)
      at peg$c204 (src/types/typeStrings/typeString_parser.ts:636:18)
      at peg$parseUserDefinedType (src/types/typeStrings/typeString_parser.ts:4380:24)
      at peg$parseSimpleType (src/types/typeStrings/typeString_parser.ts:3685:30)
      at peg$parseNonArrPtrType (src/types/typeStrings/typeString_parser.ts:5367:12)
      at peg$parseArrayPtrType (src/types/typeStrings/typeString_parser.ts:5391:10)
      at peg$parseType (src/types/typeStrings/typeString_parser.ts:5655:20)
      at peg$parseStart (src/types/typeStrings/typeString_parser.ts:901:12)
      at peg$parse (src/types/typeStrings/typeString_parser.ts:5667:16)
      at getNodeType (src/types/typeStrings/typeString_parser.ts:109:17)
      at Context.<anonymous> (test/integration/types/typestrings.spec.ts:159:53)

This is due to the fact that in normal resolving logic the Test struct shadows the contract definition for Test.

Since we are planing on deprecating the typestring parser, moving it under test/ and only using it to test the correctness of InferType we might not fix this edge case, unless there's demand for it.

@cd1m0 cd1m0 self-assigned this Oct 12, 2022
@cd1m0 cd1m0 added bug Something isn't working cac Issue discovered from running over the contract archive labels Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cac Issue discovered from running over the contract archive
Projects
None yet
Development

No branches or pull requests

1 participant