extract: C++20 requires-constrained declarations are classified as definitions

Open Beginner friendly
#195 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
71/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, rust
Domain
compilers

Research direction

Start by reading row_defines_the_function in the crate::types code and inspect the related tests for function declarations. Use the C++20 reproducer from the issue to check how the requires body and trailing semicolon are classified. Done means the call returns false for this constrained prototype while function definitions still classify correctly.

Written by the indexing model from the issue text.

Description

A C++20 prototype declaration with a requires requires(...) { ... } constraint is misclassified as a function definition by row_defines_the_function.

Reproducer

template<typename T> void f(T t) requires requires(T x) { x.y; };

crate::types::row_defines_the_function(&func.return_type, &func.body) returns true even though the declaration ends with ; and has no function body.

Cause

Documented in 8f1e3d2: row_defines_the_function checks for { outside parentheses, and a requires-clause body sits outside the parameter list's parentheses.

Expected behavior

Constrained prototypes ending in ; should be classified as declarations (row_defines_the_function(...) == false), not definitions.

Dominant language
Rust
Stars
187
Forks
53
Avg merge
1d 9h
Merged PRs (30d)
79

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from facebookexperimental/semcode

All issues in facebookexperimental/semcode

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.