Wiki

Ticket #199 (closed defect: fixed)

Opened 15 years ago

Last modified 15 years ago

Missing inout gets C# error message rather than Cobra error message.

Reported by: torial Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: error message Cc:

Description (last modified by Chuck) (diff)

If a call to a fxn that has inout parameters is made w/o the inout parameter, the C# equivalent message is given: "error: Argument "1" must be passed with the "ref" keyword" However, adding "ref" before argument 1 does not fix the issue, adding "inout" does.

%% args -ref:System.Xml -ref:System.Drawing

use System.Windows.Forms #from "System.Windows.Forms"
use System.Xml #from "System.Xml"
use System.Text.RegularExpressions
use System.Drawing

class WordMatcher inherits Form
    
    cue init
        base.init
        .text = 'TMX Word Match Finder'
        .width = 800
        .height = 600
        
        list = List<of int>()
        .getList(list) #error: Argument "1" must be passed with the "ref" keyword
        .getList(inout list) #this compiles fine if above line is commented out.
    
    
    def getList(list as inout List<of int>)
        trace list

class Program

    def main is shared
        has STAThread
        Application.run(WordMatcher())

Attachments

inout-mismatch.patch Download (3.4 KB) - added by hopscc 15 years ago.

Change History

Changed 15 years ago by Chuck

  • description modified (diff)

Nice catch. Here is a smaller program that demonstrates the bug:

class P

	def foo(x as inout int)
		x = 5

	def main
		y = 0
		.foo(y)
		assert y == 5

Changed 15 years ago by Chuck

I have added a little more "cleanup" in SharpCompilationMessage.cobra that at least improves how this reads. changeset:2296

That does not fix this ticket as the error check should still be done in Cobra, but it helps.

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

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

Fix for non checking of inout label/param mismatches.
patch + test + relnote.

Changed 15 years ago by Chuck

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

Applied in changeset:2360. Thanks.

Note: See TracTickets for help on using tickets.