hyperledger-solang / solang

Solidity Compiler for Solana and Polkadot
https://solang.readthedocs.io/
Apache License 2.0
1.26k stars 210 forks source link

`string.concat` fails during sema #1558

Closed bkushigian closed 10 months ago

bkushigian commented 11 months ago

The following code compiles with solc but fails during parse_and_resolve:

contract StringConcat {
    function concat( string memory a, string memory b) public pure returns (string memory) {
        return string.concat(a, b);
    }
}
$ solc contracts/utils/Strings.sol 
Compiler run successful. No output generated.

$ solang_parser contracts/utils/Strings.sol

=====  Error: contracts/utils/Strings.sol  =====
warning: conversion truncates uint256 to uint32, as memory size is type uint32 on target EVM
   ┌─ /openzeppelin-contracts/contracts/utils/Strings.sol:27:47
   │
27 │             string memory buffer = new string(length);
   │                                               ^^^^^^

error: type not expected
   ┌─ /openzeppelin-contracts/contracts/utils/Strings.sol:50:16
   │
50 │         return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
   │                ^^^^^^

warning: conversion truncates uint256 to uint32, as memory size is type uint32 on target EVM
   ┌─ /openzeppelin-contracts/contracts/utils/Strings.sol:67:41
   │
67 │         bytes memory buffer = new bytes(2 * length + 2);
   │                                         ^^^^^^^^^^^^^^

(note: solang_parser is an executable wrapper around solang's parse_and_resolve)