Wiki

Ticket #257 (closed enhancement: fixed)

Opened 14 years ago

Last modified 14 years ago

First use of a variable in a method out param should declare it

Reported by: hopscc Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

Local variables are created (and type inferred) on first assignment

t = 50 * 365 

Since the situation is similar the same should happen if the first time a variable is referenced it is as an out param in a method call

if d.tryGetValue(key, out result)
    print result

Currently it generates an error

error: For "tryGetValue" arg 2: Cannot find "result".

see  Discussion

Attachments

infer-out-param.patch Download (8.4 KB) - added by hopscc 14 years ago.

Change History

Changed 14 years ago by hopscc

Changed 14 years ago by hopscc

  • status changed from new to assigned
  • owner set to Chuck

Patch + tests + relnote - some refactoring.

Needed to add a warning wrt overloaded methods (with undefined out variable).

Changed 14 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Thanks. Applied in changeset:2446

Note: See TracTickets for help on using tickets.