0

I have a library which has the following function:

function strConcat(
    string memory _a,
    string memory _b
)
    internal pure
    returns (string memory)

My contract implements the library and uses the following:

using StringConverter for *;
...
uint minLevel = getStorageUint(
    r,
    ("_conf_").strConcat(pSetting),
    pSettingIndex,
    0
);

This is working, but if I change:

using StringConverter for string;

I can see the error:

TypeError: Member "strConcat" not found or not visible after argument-dependent lookup in literal_string "_conf_".
        ("_conf_").strConcat(pSetting),

What can I type at using to make it working correctly?

4
  • Can you try with for bytes32 Sep 3, 2019 at 18:38
  • Just tried, unfortunately, no effect, same error.
    – Radeg90
    Sep 3, 2019 at 18:40
  • Can you link the library you are using? Sep 3, 2019 at 18:45
  • Sure, but library is working perfectly, the problem is with using. Took it from here: ethereum.stackexchange.com/questions/729/… It's kinda outdated, so you have to change string to string memory everywhere and i to uint i in loops (just tested on remix).
    – Radeg90
    Sep 3, 2019 at 18:49

1 Answer 1

3

Try this solution:

First declare string variable:

string memory myVariable = "_conf_";

Then execute the concat.

myVariable.strConcat(pSetting);

I hope this works.

The problem you have comes arises, because

("_conf_").strConcat(pSetting)

doesn't explicitly create "_conf_" as a memory string.

5
  • 1
    This solves the problem but, to be honest, it's an ugly solution and probably more gas expensive. There must be a better way... Btw. It's not me who gave you minus.
    – Radeg90
    Sep 3, 2019 at 19:01
  • 1
    Good to know. I update my answer. Maybe you try with this one: using StringConverter for bytes; Sep 3, 2019 at 19:04
  • 1
    Bytes didn't help either. :( I'm wondering what type does represent syntax ("anything"). It says it's literal_string but there isn't so much to read about it in solidity documentation, also can't put that at "using".
    – Radeg90
    Sep 3, 2019 at 19:09
  • 1
    If you are just after keeping gas at a minimum you are best off sticking with for *. In my opinion it doesn't hurt that much. Sep 3, 2019 at 19:13
  • 1
    Okay. Thanks for your support.
    – Radeg90
    Sep 3, 2019 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.