PlayScriptRedux / playscript

PlayScript is an ActionScript compatible compiler and Flash compatible runtime that runs in the Mono/.NET environment
Other
17 stars 9 forks source link

Error CS7112: The type `String' does not contain a constructor that takes non-scalar arguments (CS7112) #107

Open sushihangover opened 8 years ago

sushihangover commented 8 years ago

Error CS7112: The type `String' does not contain a constructor that takes non-scalar arguments (CS7112)

Example valid AS code:

var array:Array = new Array("1", "2", "3");
var i:int = 0;
var line:String = new String( array[i] );

Where found: AGALMiniAssembler.as

sushihangover commented 8 years ago

Workaround:

var array:Array = new Array("1", "2", "3");
var i:int = 0;
//var line:String = new String( array[i] );
var line:String = array[i] as String;
sushihangover commented 8 years ago

ps-lang.cs

                if (sn != null && IsPlayScriptScalarClass (sn.Name) && inv.Arguments != null && inv.Arguments.Count == 1) {
                    Argument arg = inv.Arguments [0].Clone (new CloneContext ());
                    arg.Resolve (ec);
                    if (arg.Expr.Type != null) {
                        if (BuiltinTypeSpec.IsPrimitiveType (arg.Expr.Type) || arg.Expr.Type.BuiltinType == BuiltinTypeSpec.Type.String)
                            return arg.Expr;
                    }
                    // TODO: ActionScript does actually allow this, but its runtime
                    // rules are hard to implement at compile time, and this should
                    // be a rare use case, so I am leaving it as a compiler error for
                    // now.
                    ec.Report.Error (7112, loc, "The type `{0}' does not contain a constructor that takes non-scalar arguments", sn.Name);
                    return null;
                }