Skip to content

Predicates that always return nil #7230

@MeanSquaredError

Description

@MeanSquaredError

Xmake Version

latest github snapshot

Operating System Version and Architecture

Any

Describe Bug

It seems that there are a couple of places where table.find_if is used with a predicate (anonymous function) that doesn't have a return statement, so it effectively always returns nil.
Here
https://github.com/xmake-io/xmake/blob/4d9a7aeaaf2732ee846ee452f46370a29b6de038/xmake/rules/c%2B%2B/modules/gcc/support.lua#L314C47-L314C95
and here
https://github.com/xmake-io/xmake/blob/4d9a7aeaaf2732ee846ee452f46370a29b6de038/xmake/rules/c%2B%2B/modules/msvc/support.lua#L264C47-L264C95

The Lua 5.5 reference manual says

Results are returned using the return statement (see §3.3.4). If control reaches the end of a function without encountering a return statement, then the function returns with no results.

So this really looks like a bug to me, unless the Lua interpreter used by Xmake has some kind of extension that allows functions to return a value without a return statement.

Expected Behavior

Those two anonymous functions should really have return statements.

Project Configuration

Irrelevant

Additional Information and Error Logs

No additional information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions