Dynamic Variable Issue

Forgetting to typecast a dynamic record field creates general error.

The statement

“If dynamicrecord.&id = ‘1’ then…”

instead of

“If dynamicrecord.&id as string = ‘1’ then…”

causes a generalized error that doesn’t show it’s location in the code.

Can you elaborate on what “generalized error” means, and provide full test case?

FatalExcecutionEngineError

The runtime has encountered a fatal error. The address of the error was at 0x62e08c8f, on thread 0x3368. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Sometimes this happens in a way that makes it impossible to tell what line it failed on.

The test case would be my other example just now, create a dynamic dv from the JSON

{{“id”:“1234”,
“name”:“Del Stewart”,
“email”:"dstewart@xxx.com",
“first_name”:“Del”,
“last_name”:“Stewart”,
“picture”:{“data”:{“is_silhouette”:false,
“url”:“https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/p50x50/blork.jpg”}}}}

and access the ID as dv.&id instead of dv.&id as string. Note that I’m not saying dv.&id should work; but it should point out my mistake in an more informative way. I’ve actually seen it crash the compiler, but the current version at least does not do that.

Can you’ve me complete code?

The JSON is incoming from the Facebook API, so

dv:=fbClient.Get("/me?fields=id,name,email,first_name,last_name,picture") as dynamic;

is the only thing I’m leaving out and I don’t know how the dynamic is being constructed, the data I gave you is what the debugger says the string value of the dynamic variable is.

but in my experience, if you have a dynamic, and you reference a field without typecasting it, you get the error.

I would think it should generate a compiler error. If I …

s:=session[‘blork’]

where s is a string, the compiler raises the error

(E62) Type mismatch, cannot assign “Object” to “String”

I’d think not typecasting dynamic fields would generate a related compiler error. It does not and then at run time the world ends.

I’m sorry to be dense, but i need to see code i can actually compile. how does the JSON get converted into a dynamic? Can you give me an actual self-contained example that reproduces the issue?

thanx,
marc

I don’t even know how to make a dynamic record. They all come in from api’s I use. Maybe someone else can help.

right but can you give us the code that shows that FatalExecutionEngine error? It’s going to depend on the exact code for us to be able to reproduce this issue.

I will try to recreate it. What should the behavior be? Should “I := dynamicRecord.&ID” work if I is and integer or a string, or would it have to be “I := dynamicRecord.&ID as integer” (or string)?

dynamicRecord.ID would be treated as dynamic, so it would use dynamic conversion to the target type.