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

UnimplementedFeatureError with no line indication when copying an array of structs to storage #12783

Closed
barakman opened this issue Mar 12, 2022 · 18 comments · Fixed by #15432
Closed
Labels
bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. medium difficulty medium impact Default level of impact should have We like the idea but it’s not important enough to be a part of the roadmap. should report better error Error is just badly reported. Should be a proper type error - source is not fine.

Comments

@barakman
Copy link

barakman commented Mar 12, 2022

Description

I am getting an error with no indication of which line it refers to:

UnimplementedFeatureError: Copying of type struct MyStruct memory[] memory to storage not yet supported.

Environment

  • Compiler version: 0.8.12

Steps to Reproduce

Well, I need to dig through my code in order to find it, but on the compiler side, the problem is probably in ArrayUtils.cpp:

solUnimplemented("Copying of type " + _sourceType.toString(false) + " to storage not yet supported.");

Thanks :)

@barakman barakman changed the title UnimplementedFeatureError with no indication of which line it refers to UnimplementedFeatureError with no line indication Mar 12, 2022
@cameel cameel moved this to Triage in Solidity Focus Board Jul 4, 2022
@wechman
Copy link
Collaborator

wechman commented Jul 14, 2022

@barakman Thank you for your ticket! Could you share the code we can use to reproduce the issue? Hope you have managed to find it. Otherwise, even if we made adjustments you suggest, we wouldn't be sure the problem is fixed.

@cameel
Copy link
Member

cameel commented Jul 14, 2022

This looks like the same thing as #3446.

And it probably won't be implemented in the current syntax but #2435 will provide a different mechanism for the same thing.

I think we should replace the UnimplementedFeatureError with a proper error at the analysis stage. Letting it blow up in the codegen is not a great user experience. And even when we have copyof syntax will be different so will still need to block this case.

@cameel cameel changed the title UnimplementedFeatureError with no line indication UnimplementedFeatureError with no line indication when copying an array of structs to storage Jul 14, 2022
@cameel cameel added bug 🐛 should report better error Error is just badly reported. Should be a proper type error - source is not fine. labels Jul 14, 2022
@barakman
Copy link
Author

barakman commented Jul 14, 2022

@barakman Thank you for your ticket! Could you share the code we can use to reproduce the issue? Hope you have managed to find it. Otherwise, even if we made adjustments you suggest, we wouldn't be sure the problem is fixed.

With no line indication on your side, all I can do is paste my entire project here, which you'll probably agree is senseless.
I suggest that you add a line indication on your side (as pointed out in my initial message), then similar issues in the future will also include a short snippet of the client code (solidity) causing the problem.

As you might understand, the main issue in this context is not the compilation error itself, but rather the message issued by the compiler, which lacks the information required for the developer to fix (or workaround) the error.

@cameel
Copy link
Member

cameel commented Jul 14, 2022

Yeah, the error should be better.

But just to help you locate it in your particular case - you can try commenting out lines that assign something of type MyStruct stored in memory to a storage variable. If doing this makes the error go away, it's the same issue.

@timweri
Copy link
Contributor

timweri commented Jul 20, 2022

I'm interested in fixing this. Will start digging to see what I can find.

@cameel cameel added medium effort Default level of effort medium impact Default level of impact should have We like the idea but it’s not important enough to be a part of the roadmap. low effort There is not much implementation work to be done. The task is very easy or tiny. and removed medium effort Default level of effort labels Sep 27, 2022
@barakman
Copy link
Author

barakman commented Oct 2, 2022

So what's the status on this? Still getting it on solc 0.8.17.

@cameel
Copy link
Member

cameel commented Oct 4, 2022

Sorry, no one is working actively on this due to other tasks with higher priorites.

If anyone wants to pick it up and work on it, feel free. It should be relatively easy to plug with an extra check in the type checker.

@barakman
Copy link
Author

barakman commented Oct 4, 2022

There are actually two different problems embedded in this issue:

  1. UnimplementedFeatureError reported by the compiler with no line indication
  2. No support by the compiler for copying an array of structs into storage

One the one hand, I guess that you could consider both as low-priority, since 1 only requires a bit of a "dig through" in order to find the error in the code, and 2 can be worked-around by copying struct by struct into storage.

On the other hand, both are rather annoying when you (I) encounter them...

Thanks

@cameel
Copy link
Member

cameel commented Oct 4, 2022

I'm only speaking about the error message here. Copying is actually high priority and is one of the roadmap issues. It's just that it we don't think it's a good idea to allow doing it implicitly through an assignment. In #2435 we want to introduce special syntax for it to make it explicit.

@NunoFilipeSantos NunoFilipeSantos added the good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. label Dec 5, 2022
@cameel cameel removed good first issue good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. labels Dec 5, 2022
@grapevinegizmos
Copy link

Just to add my feedback that, for developers, getting an error message which gives no indication of the line of source that spawns the error can be quite tedious in a large code base. You spend a lot of time hunting in the code trying to figure out where you did such a thing,

This error was opened about a year ago and appears to be relatively low effort fix (with significant impact for those who run into it). Hope that it gets some attention.

@ekpyron
Copy link
Member

ekpyron commented Mar 6, 2023

The error should really just tell people to use --via-ir these days (which has the feature implemented for a long time).

@cameel
Copy link
Member

cameel commented Mar 6, 2023

@ekpyron But it still should not be a failing assert. It should at the very least go through an error reporter.

@ekpyron
Copy link
Member

ekpyron commented Mar 6, 2023

If the message for the assert is good enough, it is fine to keep it. We plan to drop legacy code generation anyways. The assertion message just has to be clear about what can and should be done to get around it.

@cameel
Copy link
Member

cameel commented Mar 26, 2023

I don't think an assert is ever good enough when it comes to reporting errors. It's an internal mechanism to catch bugs and very unfriendly as a way of reporting errors to tools and users.

The error should really just tell people to use --via-ir these days (which has the feature implemented for a long time).

By the way, I just realized that you must have confused this issue with #12449 (maybe I referred to it as such by mistake somewhere? I thought it was that too until I took a closer look now). This one is about the inability to copy structs, not "stack too deep". Here it's very easy for us to give the user the exact location of the error if we detect this during analysis and issue a proper error. For whatever reason we're not doing that and letting it blow up in the codegen.

davidBar-On added a commit to davidBar-On/solidity that referenced this issue Jun 11, 2023
davidBar-On added a commit to davidBar-On/solidity that referenced this issue Jun 11, 2023
davidBar-On added a commit to davidBar-On/solidity that referenced this issue Jun 11, 2023
@NunoFilipeSantos NunoFilipeSantos closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2023
@barakman
Copy link
Author

barakman commented Jul 6, 2023

Closed as not planned? Why not just fix it?

This issue (a compilation error with no line indication) is clearly a compiler issue.

@dannydoritoeth
Copy link

The error message is not helpful at all at guiding you for where to start looking for in your code for what is causing it.

It would be good to just make the error bit clearer even its not going to be fixed.

@PaulRBerg
Copy link
Contributor

Why has this issue been closed as not planned, @cameel, @NunoFilipeSantos?

@peexledev
Copy link

fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. medium difficulty medium impact Default level of impact should have We like the idea but it’s not important enough to be a part of the roadmap. should report better error Error is just badly reported. Should be a proper type error - source is not fine.
Projects
None yet