Skip to content

Commit 423dec5

Browse files
author
James Brundage
committed
Updating new keyword (fixing #142)
1 parent 8b20c81 commit 423dec5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Transpilers/Keywords/New.psx.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ process {
9797
$constructorArguments[0] -is [string]) {
9898
"[$newTypeName]::parse(" + ($constructorArguments -join ',') + ")"
9999
} elseif ($realNewType::new) {
100-
"[$newTypeName]::new(" + ($constructorArguments -join ',') + ")"
100+
if ($constructorArguments) {
101+
"[$newTypeName]::new(" + ($constructorArguments -join ',') + ")"
102+
} elseif ($realNewType::new.overloadDefinitions -notmatch '\(\)$') {
103+
"[$newTypeName]::new(`$null)"
104+
} else {
105+
"[$newTypeName]::new()"
106+
}
101107
} elseif ($realNewType.IsPrimitive) {
102108
if ($constructorArguments) {
103109
if ($constructorArguments.Length -eq 1) {

0 commit comments

Comments
 (0)