Cobra internal error with mixin
Posted: Fri Apr 17, 2015 4:54 pm
Cobra svn:3116 (post 0.9.6) / 2015-04-17 on Mono 3.12.1 CLR v4.0.30319 on Unix 3.19.3.1
OpenSuse tumbleweed
Linux 3.19.3-1-desktop #1 SMP PREEMPT Thu Mar 26 17:34:34 UTC 2015 (f10e7fc) x86_64 x86_64 x86_64 GNU/Linux
I have the following code:
when I compile I have this error:
same with cobra -verbose
Same problem with Cobra 0.9.6
Any help?, thanks
OpenSuse tumbleweed
Linux 3.19.3-1-desktop #1 SMP PREEMPT Thu Mar 26 17:34:34 UTC 2015 (f10e7fc) x86_64 x86_64 x86_64 GNU/Linux
I have the following code:
- Code: Select all
use System.Diagnostics
mixin CommandLineTool
"""
To access tools via command invocation.
"""
var _commandEnvironmentVariables = Dictionary<of String, String>()
var _commandError = false
var _exception as Exception?
var _commandOutput = ''
var _exitCode = 0
var _lastCommand as String?
get commandError from var as bool
"""
Error produced after running a command
"""
get exception from var as Exception?
"""
Exception saved in last command run.
"""
get commandOutput from var as String
"""
Output of the last command run.
"""
get exitCode from var as int
"""
Value of exit code of the last command when it terminated.
"""
get lastCommand from var as String?
"""
Last command executed
"""
# Environment variables added before run a command
def commandEnvironmentVariable(key as String) as String
require
key.length
body
return _commandEnvironmentVariables[key]
def setCommandEnvironmentVariable(name as String, value as String)
"""
Set an environment variable that will be set before run
the command. Once set it will be used every time a command
is run until it is removed.
"""
require
name.length
ensure
.commandEnvironmentVariable(name) == value
body
_commandEnvironmentVariables[name] = value
def cleanEnvironmentVariables
"""
Remove environment variables
"""
_commandEnvironmentVariables = Dictionary<of String, String>()
def runCommand(command as String, args as String)
"""
Run the tool with args as parameters
"""
require
command.length
args.length
body
p = Process()
for key, value in _commandEnvironmentVariables
p.startInfo.environmentVariables[key] = value
p.startInfo.fileName = command
p.startInfo.arguments = args
try
_commandOutput = p.runAndCaptureAllOutput.trim
_exitCode = p.exitCode
_commandError = false
_lastCommand = command + ' ' + args
catch ex as Exception
_commandOutput = ''
_commandError = true
_exception = ex
class Foo
adds CommandLineTool
cue init
base.init
def main is shared
f = Foo()
when I compile I have this error:
- Code: Select all
fraya@:~/Downloads> cobra mixin1.cobra
error: COBRA INTERNAL ERROR / InvalidCastException / Cannot cast from source type to destination type.
Compilation failed - 1 error, 0 warnings
Not running due to errors above.
same with cobra -verbose
- Code: Select all
fraya@:~/Downloads> cobra -verbose mixin1.cobra
Cobra Command Line svn:3116 (post 0.9.6) / 2015-04-17
Copyright (C) 2003-2015 by Cobra Language LLC.
OS Version: Unix 3.19.3.1
CLR Platform: Mono
CLR Version: 4.0.30319.17020
Current Directory: /home/fraya/Downloads
Current Exe: /usr/local/cobra/Cobra-svn-3116/bin/cobra.exe
Option Dictionary:
verbosity: 1
back-end: 'none'
contracts: 'inline'
copy-core: false
correct-source: Set<of String>['none']
debug: '1'
debugging-tips: true
embed-run-time: false
embed-version: 'compiler-version'
include-asserts: true
include-nil-checks: true
include-tests: true
include-traces: true
native-compiler: 'auto'
number: 'decimal'
test-runner: 'Cobra.Core.CobraCore.runAppTests'
testify-results: 'r-testify.text'
library-directory: List<of String>[]
Paths:
mixin1.cobra
Phase: Binding Cobra run-time library
Adding reference to Cobra.Core.dll
Adding reference to System.Core.dll
Phase: Reading libraries
Reading assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
at: /usr/lib/mono/4.5/mscorlib.dll
Reading assembly: System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
at: /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
Loading reference: Cobra.Core.dll
Reading assembly: Cobra.Core, Version=0.0.3116.1, Culture=neutral, PublicKeyToken=0a4783a5c7c9616e
at: /usr/local/cobra/Cobra-svn-3116/bin/Cobra.Core.dll
Loading reference: System.Core.dll
Reading assembly: System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
at: /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
Phase: Parsing source code
Phase: Binding use directives
Phase: Binding inheritance
Phase: Binding interface
Phase: Binding mixins
error: COBRA INTERNAL ERROR / InvalidCastException / Cannot cast from source type to destination type.
Compilation failed - 1 error, 0 warnings
Not running due to errors above.
Same problem with Cobra 0.9.6
Any help?, thanks