Results 1 to 6 of 6

Thread: Compiler bug

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2019
    Posts
    416

    Compiler bug

    Greetings,

    Yes I made a mistake but I got bitten hard by this in production yesterday.



    Create an empty project

    In the form load:

    dim someObject as object

    set someObject = createobject("any.valid.object")

    Create an empty function someFunction in form that accepts no arguments

    In the form load

    someFunction someObject

    compile & run

    Boom

    Access violation.

    Why does it even compile?

    EDIT

    If you make someFunction have a return value like "as boolean" then it no longer compiles

    EDIT EDIT

    if define someFuncion as a sub instead of a function it also does not compile.
    Last edited by vbwins; Jul 23rd, 2021 at 12:08 AM.

  2. #2

  3. #3
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,057

    Re: Compiler bug

    same crash in native code calling __vbaVarIndexLoad
    pcode dump more concise, trying to do an array value load after the function call for some reason.

    Code:
    401890 Form1.Form_Load:
    401890    F5 00000000           LitI4 0x0
    401895    1B 0000               LitStr str_40152C='Scripting.FilesystemObject' 
    401898    04 68FF               FLdRfVar var_98
    40189B    0A 01000C00           ImpAdCallFPR4 rtcCreateObject2
    4018A0    04 68FF               FLdRfVar var_98
    4018A3    FC34                  CAdVar
    4018A5    FCF8 78FF             FStAd var_88
    4018A9    35 68FF               FFree1Var var_98
    4018AC    04 78FF               FLdRfVar var_88
    4018AF    FD93 0940             CDargRef  0x4009 (IDisp | ByRef)
    4018B3    04 68FF               FLdRfVar var_98
    4018B6    10 F8060200           ThisVCallHresult Form1.someFunction
    4018BB    04 68FF               FLdRfVar var_98
    4018BE    FEAE 00000100         VarIndexLdVar arg_0 dim:0x1  <-- crash
    4018C4    FC8B                  PopAd
    4018C6    35 68FF               FFree1Var var_98
    4018C9    13                    ExitProcHresult

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Compiler bug

    just because i was bored, i decided to test as described, but i did not get the same error, i got the expected type mismatch trying to pass the object to a function with no parameters
    with a return for the function i got "wrong number of arguments or invalid property assignment"

    maybe the description wasn't clear enough for me
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Compiler bug

    Quote Originally Posted by westconn1 View Post
    just because i was bored, i decided to test as described, but i did not get the same error, i got the expected type mismatch trying to pass the object to a function with no parameters
    with a return for the function i got "wrong number of arguments or invalid property assignment"

    maybe the description wasn't clear enough for me
    Same here, Type mismatch error, no compile.

  6. #6

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width