Author pablogsal
Recipients gvanrossum, lys.nikolaou, pablogsal
Date 2020-09-08.20:31:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Casting incorrect elements pulled from asdl_seq objects has been a pain when developing the new PEG parser and is a source of spooky-bug-at-a-distance problems in which the consequences of an incorrect casting from void* are felt much later.

I propose to add a new field to asdl_seq objects, which is an enumeration of the possible types it can contain. The main ideas are:

* By default, the enumeration will have UNDEFINED type.
* We can add some extra macros mirroring asdl_seq_GET and asdl_seq_SET that will receive the expected type and in debug mode will assert that the type is correct. Something like:

expr_ty item = asdl_set_GET_TYPED(sequence, n, EXPR);

* Usage of asdl_seq_GET and asdl_seq_SET do not do extra checks.

* To set the type information, we can add a new constructor:

asdl_seq_new_typed(size, arena, TYPE);

I think this change is worth because is not very invasive (old usage remains the same), we can slowly migrate only the parts that we need/want and will add some extra debugging possibilities for cases that has been quite challenging.
Date User Action Args
2020-09-08 20:31:17pablogsalsetrecipients: + pablogsal, gvanrossum, lys.nikolaou
2020-09-08 20:31:17pablogsalsetmessageid: <>
2020-09-08 20:31:17pablogsallinkissue41746 messages
2020-09-08 20:31:17pablogsalcreate