adamedx / scriptclass

Class definition extensions for PowerShell's object-based type system
Apache License 2.0
7 stars 1 forks source link

Undefined variable used in classdsl for strict-val when an incorrectly formatted type name is given #37

Closed adamedx closed 1 year ago

adamedx commented 1 year ago

Describe the bug If an incorrect type name is specified to strict-val, an exception occurs, but the error is actually a bug in scriptclass that masks the correct error message. ScriptClass tries to print the typename for a useful error message but generates a different exception instead.

To Reproduce

scriptclass ErrorProp {
  strict-val BadProp typename_without_brackets $null
}

The following error is shown because the variable $propTypeName does not exist anywhere in the module. It should be fixed to just use $type which has the bad name for the correct error message.

Expected behavior An error message indicating that the type name was not correctly formatted because it was missing the surrounding square brackets.