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

Cannot call toString() on a list of non-literal expressions #340

Open
m0nac0 opened this issue Jul 22, 2021 · 3 comments
Open

Cannot call toString() on a list of non-literal expressions #340

m0nac0 opened this issue Jul 22, 2021 · 3 comments

Comments

@m0nac0
Copy link

m0nac0 commented Jul 22, 2021

Whenever I try to use literalList() and pass non-literal expressions, I get the error:
Not a supported literal type

According to #225 this should be supported, though.

@srawlins
Copy link
Member

Please provide a minimal reproduction case. What code do you try to run which produces this error?

@m0nac0
Copy link
Author

m0nac0 commented Jul 23, 2021

When I tried to provide the minimal reproduction case, I noticed that the same code I couldn't get to work yesterday seems to work fine today. So it seems to have been some other issue on my side. Thank you nonetheless for responding!

@m0nac0 m0nac0 closed this as completed Jul 23, 2021
@leonsenft
Copy link

I ran into this issue and I think the root cause is LiteralListExpression.toString()'s implementation:

String toString() => '[${values.map(literal).join(', ')}]';

It passes each value to literal() which is what throws the reported error:

throw UnsupportedError('Not a supported literal type: $literal.');

I encountered this issue rather indirectly via the equalsDart matcher, because it invokes toString() in order to describe a mismatch.

I'm not very familiar with this code base, but I wonder if simply calling toString(), instead of literal(), on each value would be sufficient?

@leonsenft leonsenft reopened this Nov 22, 2021
@leonsenft leonsenft changed the title Cannot generate a list of non-literal expressions Cannot call toString() on a list of non-literal expressions Nov 22, 2021
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

3 participants