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

Implement assert() messages #24213

Closed
7 tasks done
munificent opened this issue Aug 26, 2015 · 23 comments
Closed
7 tasks done

Implement assert() messages #24213

munificent opened this issue Aug 26, 2015 · 23 comments
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). type-enhancement A request for a change that isn't a bug
Milestone

Comments

@munificent
Copy link
Member

munificent commented Aug 26, 2015

The DEP committee feels Seth's proposal for an optional message to assert() is far enough along to be ready for a real implementation.

the implementation should be gated behind a flag called "assert-message".
The implementations can and should now remove the flag.

This is the main tracking bug. Each implementation's specific bug is below:

@munificent
Copy link
Member Author

Hey, @jmesserly or @vsmenon, do you want to file a relevant bug for DDC?

@mit-mit mit-mit added this to the 1.13 milestone Sep 3, 2015
@mit-mit mit-mit added the area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). label Sep 3, 2015
@sethladd
Copy link
Contributor

@gbracha can you provide any updates from the DEP's discussion on whether the optional param can be type annotated with dynamic or String ?

Thanks!

@sethladd
Copy link
Contributor

From a chat with @gbracha : The type annotation for the optional parameter will be a String.

@sethladd sethladd modified the milestones: 1.14, 1.13 Oct 1, 2015
@sethladd
Copy link
Contributor

sethladd commented Oct 1, 2015

Bumping to 1.14, not a critical 1.13 thing

@kevmoo kevmoo modified the milestones: 1.14, 1.15 Jan 13, 2016
@sethladd
Copy link
Contributor

sethladd commented Feb 1, 2016

Not sure what the status of this is.

@sethladd sethladd removed their assignment Feb 1, 2016
@munificent
Copy link
Member Author

As far as I can tell:

  • The landed patch to dart2js allows any object and it is converted to a string when the AssertionError exception is printed.
  • The not-landed patch to analyzer reports a static warning if the message is not assignable to a string.

I believe the consensus opinion on the DEP committee is that any object should be allowed.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
@mit-mit
Copy link
Member

mit-mit commented Mar 2, 2016

Clearing out 1.15 milestone as the last full push to dev has happened. If any changes are required before 1.15 is shipped, please file a merge request

@mit-mit mit-mit modified the milestones: 1.16, 1.15 Mar 2, 2016
@kevmoo kevmoo removed this from the 1.16 milestone Apr 19, 2016
@bwilkerson
Copy link
Member

Are we leaving the support behind a flag for 1.50, or are we removing the flag?

@sethladd
Copy link
Contributor

sethladd commented Dec 8, 2016

Curious, what was implemented? https://github.com/sethladd/dep_assert_with_optional_message/blob/master/proposal.md or something else?

@bwilkerson
Copy link
Member

Something more general. The message is allowed to be any expression (not just a string literal).

@mit-mit
Copy link
Member

mit-mit commented Dec 13, 2016

Marking VM complete based on https://codereview.chromium.org/2564623003/

@munificent
Copy link
Member Author

Not quite there yet: #24215 (comment)

@mit-mit mit-mit modified the milestones: 1.22, 1.50 Dec 14, 2016
@mit-mit
Copy link
Member

mit-mit commented Dec 14, 2016

Moving to 1.22, we need to get this completed.

@mit-mit mit-mit changed the title Implement assert() messages behind a flag Implement assert() messages Dec 14, 2016
@mit-mit
Copy link
Member

mit-mit commented Dec 14, 2016

Removing behind a flag from title also now that we are ready to not have this flagged

@dgrove
Copy link
Contributor

dgrove commented Dec 16, 2016

Now that #24215 is closed, is there any reason that this should not be closed as well?

@mit-mit
Copy link
Member

mit-mit commented Dec 16, 2016

@munificent do we have tests in place?

Also, we should spec somewhere what we actually added (which sounds like it was different from the DEP).

@eernstg
Copy link
Member

eernstg commented Dec 16, 2016

That's the spec of 'General expressions in assert', which just allows you to use an expression rather than a conditionalExpression as the single argument to assert. This issue is about passing two arguments to assert, the second of which would be used as a message. The discussions were about the typing of that second argument, I believe, and the evaluation (insist on string? just call toString()?).

@mit-mit
Copy link
Member

mit-mit commented Dec 16, 2016

Did some basic testing passing this program to a recent build:

main() {
  assert(2 > 1, 'Math is broken');
  var v;
  assert(v != null, 'v is null');
}

@munificent
Copy link
Member Author

munificent commented Dec 16, 2016

@munificent do we have tests in place?

Yes, but they are a little scattered:

  • The dartjs folks added tests/compiler/dart2js_extras/assert_with_messages.test
  • The VM folks added test/language/assert_message.test
  • For DDC, I added test/language_strong/assert_with_messages.test
  • Dartfmt, as usual has its own tests.
  • Analyzer too.

The latter two make sense to be different. I think we should eventually unify the first three. A lesson I took away from this is that the language team should try to manage testing a new feature so that we don't pawn it off on the implementers and get redundant or spotty tests.

@stereotype441
Copy link
Member

A lesson I took away from this is that the language team should try to manage testing a new feature so that we don't pawn it off on the implementers and get redundant or spotty tests.

I like the sound of this. It would go a long way toward helping to avoid confusion when different teams have different ideas about to interpret the spec, or how corner cases should be handled.

@munificent
Copy link
Member Author

I like the sound of this. It would go a long way toward helping to avoid confusion when different teams have different ideas about to interpret the spec, or how corner cases should be handled.

Yeah, I totally agree. Leaf and I talked about this yesterday.

At the same time, I don't want the language team to implement all of the tests. Aside from having limited bandwidth, I think it's really useful to get help from people such as yourself who are really skilled at coming up with all of the tricky edge cases that we want to test.

So I'm thinking it should be a collaborative process, but the language team should probably own setting up the framework that the implementers can put tests into.

@stereotype441
Copy link
Member

Sounds good to me.

@mit-mit
Copy link
Member

mit-mit commented Dec 20, 2016

Closing this for 1.22 as the last item (#28136) landed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants