[SERVER-68848] IDLParserContext unary constructor missing "explicit" Created: 15/Aug/22  Updated: 29/Oct/23  Resolved: 17/Aug/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-66708 Ensure deserializer methods for IDL ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2022-08-22
Participants:

 Description   

IDLParserContext unary constructor missing "explicit".
This constructor takes a StringData, which means a StringData is usable where an IDLParserContext is expected. This is not the right way to do it, and it's confusing because StringData is itself implicitly convertible from so many things, and none of THOSE things are usable as IDLParserContext, so people either use ""_sd literals or braces around a string literal to force the construction of a StringData argument.

The IDLParserContext is not a string-like type and should not be implicitly convertible from StringData. If the IDL-generated parse functions want to have an overload that takes StringData, that's one thing, but that's not what this is.

Related to SERVER-66708, where IDLParserContext constructors are having a hard time being properly defined because of these use cases relying on the implicit constructor.

Recommendation is to make the constructor explicit and fix all call sites.



 Comments   
Comment by Githook User [ 16/Aug/22 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-68848 explicit IDLParserContext unary ctor
Branch: master
https://github.com/mongodb/mongo/commit/fa82903f53a8e779ba0414849846c4c072b5a1e8

Comment by Githook User [ 16/Aug/22 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-68848 IDLParserContext explicit unary ctor
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/6dd6c6d6dd0b8e167cdf38ea4785716e0249d77a

Generated at Thu Feb 08 06:11:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.