-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When we mention empty string in GUID then system is not throwing correct Error #4912
Comments
Al Compiler version is 3.0.106655 |
Have you tried comparing with a null Guid? |
A null GUID is a GUID will zeros in every position - you can't compare a GUID to a string without that string being castable to a GUID. The string Is the |
So the solution is comparing with a null Guid (just define a variable of type Guid a do NOT give it a value). I guess you could wish for the compiler finding this at compile time to avoid getting it at runtime. |
@AskeHolst you can just use:
|
Even better solution with the IsNullGuid(), lets hope the original poster @srinivasbanny is reading this. It still leaves the general compiler question of checking types at compile time. Which is why this question might be relevant here. |
@AskeHolst exactly that is what my question is, if i am trying to define this as a string then compiler should give some error not to allow us to build the app at least |
@AskeHolst but there's no reason to use a string as a way to check against this GUID here. GUID literals could be useful in other cases - there are a few places in NAV/BC where a notification ID is re-used so that the notifications don't stack (for example the Dynamics 365 sync. code). This GUID is a string literal which is casted to a GUID at runtime, but there's no reason for it to be in future if literals were implemented. @srinivasbanny I don't follow in your case here - you need to test the value of As stated though, GUID literals might be useful in future in order to create compile time constants. |
@charlespockert I think you are missing the point of compiler checks: That developers make mistakes. |
@AskeHolst I'm not missing the point, I'm just saying that I agree, developers make mistakes, but it's a developers job to educate themselves on the type system and understand not to expect a string cast (which could be any value at runtime) to be checked at compile time. |
AL behaviour seems to have changed here.
Tested with on-prem BC 13 cumulative upd 3 (no error) and on-prem BC 14 (error). There are multiple fixes possible, but it is curious that this AL behaviour has been changed. |
Hi! The behavior you see in 14.0.* is the correct one and it is mostly related to legacy code. In C/AL, whenever a Guid was compared with a String-like type, behind the scenes, the String was parsed into a Guid and the comparison was performed between two Guids. |
i have written code
IF SMTPMailSetup."Password Key" = '' then
Error('Password is empty ');
but when i tried to execute the above code system is throwing error instead of giving empty string error
Invalid format of GUID string. The correct format of the GUID string is: CDEF7890-ABCD-0123-1234-567890ABCDEF where 0-9, A-F symbolizes hexadecimal digits.
solution should be, compiler should find the issue and should not allow to create app
The text was updated successfully, but these errors were encountered: