Wiki

Ticket #208 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

Dynamics not finding shared members (and it seems instance members too)

Reported by: nevdelap Owned by: Chuck
Priority: minor Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

mono = Assembly.load('Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken?=0738eb9f132ed756')

Currently this throws Cobra.Lang.UnknownMemberException?

unixFileSystemInfo as dynamic? = mono.getType('Mono.Unix.UnixFileSystemInfo?')
fileInfo as dynamic? = unixFileSystemInfo.getFileSystemEntry('/usr/local/bin/cobra')

Workaround is to call invokeMethod...

unixFileSystemInfo2 as Type = mono.getType('Mono.Unix.UnixFileSystemInfo?')
fileInfo as dynamic? = unixFileSystemInfo2.invokeMember('GetFileSystemEntry?', BindingFlags?(Static, InvokeMethod?).InvokeMethod?, nil, nil, @[/usr/local/bin/cobra?])

The complete example program is in...

 http://cobra-language.com/forums/viewtopic.php?f=4&t=628&p=3174#p3174

Change History

in reply to: ↑ description   Changed 14 years ago by nevdelap

  • summary changed from Dynamics don't find instance members. to Dynamics not finding shared members (and it seems instance members too)

(The title should have been shared members to start with.)

Further, doing this works...

unixFileSystemInfo2 as Type = mono.getType('Mono.Unix.UnixFileSystemInfo??')
fileInfo as dynamic? = unixFileSystemInfo2.invokeMember('GetFileSystemEntry??',

Doing this doesn't...

unixFileSystemInfo2 as dynamic? = mono.getType('Mono.Unix.UnixFileSystemInfo??')
fileInfo as dynamic? = unixFileSystemInfo2.invokeMember('GetFileSystemEntry??',

The invokeMember() is not static, but has the same issue saying it can't find the member for InvokeMember?.

  Changed 14 years ago by Chuck

  • owner set to Chuck
  • status changed from new to assigned
  • type changed from enhancement to defect

Stand-alone, small test case:

class Test

	shared
	
		def two as int
			return 2

		get three as int
			return 3

		def double(i as int) as int
			return i * 2

		def main
			t = Test to dynamic
			assert t.two == 2
			assert t.three == 3
			assert t.double(4) == 8

  Changed 14 years ago by nevdelap

Ah, interesting. It's much more fundamental and I was off on tangents. Goodo.

  Changed 14 years ago by Chuck

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

Your essential report was correct. This is just my usual "reduction" to create a focused test for our regression test suite.

Now fixed in changeset:2401. Thanks for the report.

Note: See TracTickets for help on using tickets.