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

Error: Top level UserDefinedValueTypeDefinition not supported #1026

Closed
bearpebble opened this issue Jan 28, 2022 · 1 comment
Closed

Error: Top level UserDefinedValueTypeDefinition not supported #1026

bearpebble opened this issue Jan 28, 2022 · 1 comment

Comments

@bearpebble
Copy link
Contributor

I'm trying to use slither on a project that makes use of user defined value types. Basically the example from this post.
I'm using the latest slither release at the time (0.8.2).

Example contract that triggers the issue:

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.8;

// Represent a 18 decimal, 256 bit wide fixed point type
// using a user defined value type.
type UFixed is uint256;

/// A minimal library to do fixed point operations on UFixed.
library FixedMath {
    uint constant multiplier = 10**18;

    /// Adds two UFixed numbers. Reverts on overflow, 
    /// relying on checked arithmetic on uint256.
    function add(UFixed a, UFixed b) internal pure returns (UFixed) {
        return UFixed.wrap(UFixed.unwrap(a) + UFixed.unwrap(b));
    }
    /// Multiplies UFixed and uint256. Reverts on overflow,
    /// relying on checked arithmetic on uint256.
    function mul(UFixed a, uint256 b) internal pure returns (UFixed) {
        return UFixed.wrap(UFixed.unwrap(a) * b);
    }
    /// Take the floor of a UFixed number.
    /// @return the largest integer that does not exceed `a`.
    function floor(UFixed a) internal pure returns (uint256) {
        return UFixed.unwrap(a) / multiplier;
    }
    /// Turns a uint256 into a UFixed of the same value.
    /// Reverts if the integer is too large.
    function toUFixed(uint256 a) internal pure returns (UFixed) {
        return UFixed.wrap(a * multiplier);
    }
}


contract Greeter {
    using FixedMath for UFixed;
    UFixed public someValue;

    constructor(string memory _greeting) {
    }
}

The output of slither . is

Traceback (most recent call last):
  File "/home/xxx/.local/lib/python3.10/site-packages/slither/__main__.py", line 743, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/xxx/.local/lib/python3.10/site-packages/slither/__main__.py", line 84, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/xxx/.local/lib/python3.10/site-packages/slither/__main__.py", line 67, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/xxx/.local/lib/python3.10/site-packages/slither/slither.py", line 97, in __init__
    parser.parse_top_level_from_loaded_json(ast, path)
  File "/home/xxx/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 270, in parse_top_level_from_loaded_json
    raise SlitherException(f"Top level {top_level_data[self.get_key()]} not supported")
slither.exceptions.SlitherException: Top level UserDefinedValueTypeDefinition not supported
Error:
Top level UserDefinedValueTypeDefinition not supported
Please report an issue to https://github.com/crytic/slither/issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants