Skip to main content

cpp_field_expression_receiver

Function cpp_field_expression_receiver 

Source
pub fn cpp_field_expression_receiver(field: Node<'_>) -> Option<Node<'_>>
Expand description

The expression a field access reads its member from.

That is normally the node in the argument field. A preprocessor conditional inside a call’s argument list defeats the grammar: tree-sitter ends the argument list at the #if line, then reads the text that follows #endif as a field access on the whole call expression and leaves the real receiver in an ERROR node between the argument child and the operator. mbedtls writes exactly that at library/ssl_tls.c:4999, where ssl->session->encrypt_then_mac is one conditionally compiled call argument (#2982).

. and -> read whatever ends immediately before them in either tree, so answer from the operator’s position instead of trusting the argument field, and unwrap the single expression a displaced ERROR holds.