Skip to content
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

Missing type promotion in user defined functions with function inlining #1284

Open
mschoeb opened this issue Jan 23, 2025 · 0 comments
Open
Labels

Comments

@mschoeb
Copy link
Collaborator

mschoeb commented Jan 23, 2025

A user defined function taking a float does not automatically promote an int to float but fails instead. The reason seems to be that function inlining translates the fucntion into a flwor expression with the treat iterator being too strong (not allowing promotion). Disabling function inlining fixes the issue for this specific example

Example:

declare function local:square($arg as xs:float) as xs:float { $arg * $arg }; 
local:square(7)
FunctionRuntimeIterator | local | <anonymous> | simple | non-sequential | Variable dependencies: 

ProgramIterator | local | xs:float | simple | non-sequential | Variable dependencies: 
  StatementsWithExprIterator | local | xs:float | simple | non-sequential | Variable dependencies: 
    TreatIterator | local | xs:float | simple | non-sequential | Variable dependencies: 
      ReturnClauseSparkIterator | local | Variable dependencies: 
        LetClauseSparkIterator
                    Dynamic context variable dependencies: 
                    Input variable dependencies: 
                    Output variable dependencies: arg(FULL) 
                    Variables bound in current FLWOR: arg 
                    Height: 0
                    Limit: -1
          Variable arg
          IntegerRuntimeIterator | local | xs:integer | simple | non-sequential | Variable dependencies: 
        StatementsWithExprIterator | local | xs:integer | simple | non-sequential | Variable dependencies: arg(FULL) 
          MultiplicativeOperationIterator | local | xs:integer | simple | non-sequential | Variable dependencies: arg(FULL) 
            VariableReferenceIterator | local | xs:integer | simple | non-sequential | Variable dependencies: arg(FULL) 
            VariableReferenceIterator | local | xs:integer | simple | non-sequential | Variable dependencies: arg(FULL) 

⚠️  ️There was an error on line 2 in file:/Users/marco/Documents/MscThesis/repo/rumble/:

                                                                                local:square(7)
                                                                             ^

Code: [XPTY0004]
Message: xs:int is not expected here. The expected type is xs:float
@mschoeb mschoeb added the Bug label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant