Skip to content

Add support for from_utf8 and string handling #662

@Stevengre

Description

@Stevengre

The from_utf8 function from Rust's stdlib is currently not included in our SMIR JSON because it is not polymorphic. This function is essential for UTF-8 string conversion and will be needed for proper string support in the system.

Current Situation

  • from_utf8 is a non-polymorphic stdlib function (source)
  • The function internally uses transmute (visible in the _unchecked version)
  • String support is currently not implemented in the system
  • Functions like amount_to_ui_amount and ui_amount_to_amount will require string support

Technical Details

The from_utf8 function performs UTF-8 validation and conversion from byte arrays to strings. Since it ultimately calls transmute for the unsafe conversion, special handling may be required when implementing this in SMIR.

Tasks

  • Analyze the special handling needed for transmute operations in from_utf8
  • Implement string type support in SMIR
  • Add from_utf8 function support
  • Update amount_to_ui_amount and ui_amount_to_amount to handle strings
  • Add appropriate test cases for string conversions

Priority

Low/Medium - Marked as non-urgent task, but will be required for full functionality

Related Components

  • SMIR JSON serialization
  • Standard library function support
  • String type handling
  • Functions: amount_to_ui_amount, ui_amount_to_amount

References

Labels

enhancement, stdlib-support, type-system, non-urgent

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-tokenrequired for supporting P-token code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions