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

Best effort assert printing #772

Merged
merged 8 commits into from Jun 9, 2021
Merged

Conversation

erights
Copy link
Contributor

@erights erights commented Jun 8, 2021

Fixes #729

@dckc I should still take your suggestion to give detailsTokens their own toString method. However, that solves less of the problem. For example, the test case added in this PR would still fail. Instead, where the assert module itself stringifies something directly, not through details, it would now stringify the quote of it. IOW, it would use bestEffortStringify.

Since I don't yet know how to reproduce #729, I'll start with this PR, and take your suggestion later after we see if this PR solves your problem.

@erights erights requested a review from dckc June 8, 2021 06:08
@erights erights self-assigned this Jun 8, 2021
@dckc
Copy link
Collaborator

dckc commented Jun 8, 2021

I can check whether this addresses the specific case that I reported, but ...

the whole agoric-sdk seems to assume that anything can be stringified. For example, the `${s}` idiom for coercing unknown to string -- I don't think it's expected to throw. While it's evidently not 100% true that everything can be stringified, I think we're better off not purposefully creating objects that throw on `${obj}`.

@dckc
Copy link
Collaborator

dckc commented Jun 8, 2021

Meanwhile, to reproduce the problem:

build xst

git clone https://github.com/Moddable-OpenSource/moddable
cd moddable
export MODDABLE=$PWD
export PATH="${MODDABLE}/build/bin/mac/release:$PATH"
cd xs/makefiles/mac
make

run a 1-liner

$ xst -e 'print(`${{ __proto__: null }}`)'
TypeError: ?: cannot coerce object to string

@erights
Copy link
Contributor Author

erights commented Jun 9, 2021

@dckc this is now ready for review. PTAL

Copy link
Collaborator

@dckc dckc left a comment

Choose a reason for hiding this comment

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

good stuff.

I made one editorial suggestion for you to consider.

packages/ses/src/error/assert.js Outdated Show resolved Hide resolved
packages/ses/src/error/assert.js Show resolved Hide resolved
@erights erights merged commit 5a486cf into master Jun 9, 2021
@erights erights deleted the 729-markm-printing-details-token branch June 9, 2021 23:50
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

Successfully merging this pull request may close these issues.

cannot coerce detailsToken to string
3 participants