Skip to content

Report errors on SimpleRenderer on missing getters #2670

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

Merged
merged 7 commits into from
Jun 8, 2021

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented Jun 7, 2021

Fixes #2667

If Mustachio is resolving a key and it finds a SimpleResolver (a resolver for a type not visible to Mustachio), and the key is a getter on that type, then Mustachio will throw an error rather than continue to other types up the stack.

@google-cla google-cla bot added the cla: yes Google CLA check succeeded. label Jun 7, 2021
@coveralls
Copy link

coveralls commented Jun 8, 2021

Coverage Status

Coverage decreased (-0.5%) to 57.543% when pulling 37a024f on srawlins:simple-resolver-error into b6fe5dd on dart-lang:master.

@srawlins srawlins requested a review from jcollins-g June 8, 2021 03:41
Copy link
Contributor

@jcollins-g jcollins-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

var type = context.runtimeType;
throw MustachioResolutionError(node.keySpan.message(
'$firstName is a getter on $type, which is not visible to Mustache. '
'To render $firstName on $type, make it visible to mustache; to '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be more specific to help with maintenance, e.g. add to visibleTypes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if (this is SimpleRenderer && _invisibleGetters.contains(names.first)) {
var type = context.runtimeType;
throw MustachioResolutionError(node.keySpan.message(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: This seems like it should work, but there is no end to end test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, there were definitely bugs :P added two tests after fixing the bugs.

@srawlins srawlins merged commit 02a467b into dart-lang:master Jun 8, 2021
@srawlins srawlins deleted the simple-resolver-error branch June 8, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'simple' resolvers should somehow warn in mustachio if a parent node resolves for them
3 participants