Jarmo makes good points and provided an alternative solution of using Column("name")[]. As mentioned by Jarmo, using Column("name")[] doesn't look as nice in the Formula Editor. My solution below does not go into that option, but it explains why this is confusing for a lot of users. It does repeat a lot of what Jarmo has already posted, but since I already had it typed...
Actually what the OP script illustrates is not a bug. This is expected behavior, and it illustrates a confusion that a lot of users have with referencing columns and how column formula evaluation works.
At the crux of the confusion is understanding the difference between Column("name") syntax and :name syntax. Both are legitimate ways to refer to columns in some circumstances, but what they return is different. Specifically, Column("name") returns a reference to a column object while :name returns the value in the name column on the current row. By the way, :name is the operator form of the function As Column("name"). In other words, those are exactly the same thing.
Consider the following example script to illustrate. This script assumes you have the Cars.jmp data table open and current in your JMP session.
Names Default To Here(1);
dt = Open( "$SAMPLE_DATA/Cars.jmp" );
// sending messages to a column; either syntax works
Column(dt, "Year") << Set Property("Range Check", LELE(87, 97));
dt:Head IC << Set Property("Spec Limits", {LSL( 150 ), Show Limits( 1 )});
// Return values
// returns a column object reference shown as Column( "Year" ) in log
Column(dt, "Year"); // returns Column( "Year" )
// returns value in Year column on the current row.
// Since current row is 0 (the default invalid row number), returns missing (.)
:Year; // returns .
// Set the current row to the first row
Row() = 1;
:Year; // returns 87
With that information in mind, it should be clear that JMP cannot calculate the mean of a set of column references. This is why the first column formula does not evaluate successfully. The Mean() function needs values - which are provided in the second column formula. As a data table evaluates the column formulas, it sets the current row to 1 then evaluates the expression stored in the Formula property. It places the return value in the column's cell in the current row. Then it sets the current row to the next value and repeats. These steps are repeated until the formula is evaluated for the last row. Consequently, the syntax of the column formula must be one that can evaluate for each row of the data table.
To me, there is one unexpected result from your example script. Namely that the syntax As Column(Column("name")) evaluates the same as As Column("name"). I expected that it would throw an error, but JMP accepts it and interprets the intent correctly. That is the (sometimes) advantage of a scripting language over a formal programming language. However, I would not recommend employing this syntax as it may fail in the future.
I think the best way to accomplish the goal given the example script is to drop the first approach at a column formula and use the second approach. The additional change is to define ColList to be a list of column names instead of column references. Here is a modified version of the OP script example that should be robust.
dt = Open( "$SAMPLE_DATA/Cars.jmp" );
ColList = {};
For( i = 1, i <= N Cols(), i++,
If( Column( i ) << GetDataType == "Numeric",
Insert Into( ColList, Column( i ) << Get Name )
)
);
MeanExpr2 = Name Expr( Mean() );
For( i = 1, i <= N Items( ColList ), i++,
Insert Into( MeanExpr2, Name Expr( As Column( ColList[i] ) ) )
);
Eval( Eval Expr( dt << New Column( "Average of numerics 2", Formula( Expr( Name Expr( MeanExpr2 ) ) ) ) ) );