Fix compiler bug with nested optional arguments
This commit fixes compiler bug where it fails when optional values are compiled into absent values in nested calls. - Throw exception with more context for easier future debugging. - Add better validation of argument values for nested calls. - Refactor `FunctionCallCompiler` for better clarity and modularize it to make it more maintainable and testable. - Refactor related interface to not have `I` prefix, and function/variable names for better clarity. Context: Discovered this issue while attempting to call `RunInlineCodeAsTrustedInstaller` which in turn invokes `RunPowerShell` for issue #246. This led to the realization that despite parameters flagged as optional, the nested argument compilation didn't support them.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ISharedFunction, ISharedFunctionBody, FunctionBodyType } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
|
||||
import { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
|
||||
import { IFunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/IFunctionCall';
|
||||
import { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
|
||||
import { FunctionParameterCollectionStub } from './FunctionParameterCollectionStub';
|
||||
import { FunctionCallStub } from './FunctionCallStub';
|
||||
|
||||
@@ -16,7 +16,7 @@ export class SharedFunctionStub implements ISharedFunction {
|
||||
|
||||
private bodyType: FunctionBodyType = FunctionBodyType.Code;
|
||||
|
||||
private calls: IFunctionCall[] = [new FunctionCallStub()];
|
||||
private calls: FunctionCall[] = [new FunctionCallStub()];
|
||||
|
||||
constructor(type: FunctionBodyType) {
|
||||
this.bodyType = type;
|
||||
@@ -53,7 +53,11 @@ export class SharedFunctionStub implements ISharedFunction {
|
||||
return this;
|
||||
}
|
||||
|
||||
public withCalls(...calls: readonly IFunctionCall[]) {
|
||||
public withSomeCalls() {
|
||||
return this.withCalls(new FunctionCallStub(), new FunctionCallStub());
|
||||
}
|
||||
|
||||
public withCalls(...calls: readonly FunctionCall[]) {
|
||||
this.calls = [...calls];
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user