Hello im trying to compile my simple code of haxe , and it still an error with Meal.hx:1: characters 0-7 is missing ;
i dont know where the error is,
here's the code:
Meal.hx
package MyFridge;
class Meal
{
public var name : String;
public function new(f_name : String)
{
this.name = f_name;
}
}
The class syntax looks valid.
So, Just some double checks;
is this the exact code?
is the file named Meal.hx?
is it located in a folder (package) called MyFridge? Btw, not sur if this makes a difference, but it is common to use lowercase packages/foldernames.
is this the only error?
if this is part of a larger project, try create a separated test, to make sure the error is really related to this file.
The package name can only contain lowercase letters.
Like this:
package myfridge;
Give that a try.
Look after the package myFridge
and uppercase from the code it will take effect for the compiler. good luck :)
Related
I am trying this simple code to split a string to a list by a separator:
open String;;
let ss = "/usr/bin/ocaml";;
let sslist = String.split_on_char '/' ss in
print_endline sslist;;
It is giving error:
$ ocaml testing.ml
File "testing.ml", line 5, characters 13-33:
Error: Unbound value String.split_on_char
I am sure it is something very basic but I am not able to solve it. Removing open String or using #require "string" also does not work.
Where is the problem and how can it be solved? Thanks for your help.
String.split_on_char is only available since 4.04.0, as per the docs.
You really should upgrade, but in case you can't, refer to this question for alternatives.
I created my xtext grammar, and now I use sirius to model, the problem I have is when I create an element from the palette (eg I create a button), In the file that takes the extension of the xtext in my case 'instance.pfe' I find a space error, the space given by modeling is not the same in the grammar .
I did not understand where this error came from , And how to solve it, thank you for helping me.
this is an example
My grammar
you should not make use of spaces inside keywords. this will have all kinds of wired sideeffects like the one you are facing.
so insteadof using
SomeRule: 'somekeyword : ' somevalue=INT
you should use
SomeRule: 'somekeyword' ':' somevalue=INT
if you really want to enforce a space then introduce a terminal for it
terminal SPACE: ' ';
SomeRule: 'somekeyword' SPACE ':' SPACEsomevalue=INT
Update:to enable class splitting
parserGenerator = {
options = {
classSplitting = true
}
}
I'm using PHPStorm EAP version PS-138.940.
I have code as follows:
Config(__NAMESPACE__."\ObjectsToIdentifiers")->oldTables = array('Modules\Old\Model\DeviceStock','Modules\Old\Model\ProductPack','Modules\Old\Model\SpareStock','Modules\Old\Model\ConsumStock');
The functionality is irrelevant in this case. Important are the entries in the array. These are fully qualified class names - the leading / is omitted, but adding it doesn't solve my problem. I want to be able to click inside one of the string literals, press Ctrl+B and be redirected to the class definition.
Note that this works in ExtJS (javascript framework) where a string literal like
"MyApp.namespace.view.MyComponent"
will take me there.
Is there any way to manually configure this or do I have to submit a feature request. If so, how can I do that?
Update 1:
I created a feature request on JetBrains Youtrack: http://youtrack.jetbrains.com/issue/WI-24262
Came across this question looking for something in Storm that would let me quickly convert "\Some\ClassName" to Some\ClassName::class like an Intention or plugin, but so far have found nothing.
i'm surprised the ::class static property hasn't been mentioned. It produces the FQN of the Class, and resolves from import aliases.
The following should be a legit rewrite that the IDE can resolve:
// Same __NAMESPACE__, so no prefix needed
Config(ObjectsToIdentifiers::class)
->oldTables = [
Modules\Old\Model\DeviceStock::class,
Modules\Old\Model\ProductPack::class,
Modules\Old\Model\SpareStock::class,
Modules\Old\Model\ConsumStock::class
];
// or, if you import the classes:
use Modules\Old\Model\DeviceStock as OldDeviceStock;
// you can refer to
OldDeviceStock::class;
Unfortunately, right now if you jump-to-definition of the alias, Storm won't take you to the actual class, but where the alias is defined. Not terribly helpful, but gets you halfway since the actual class is right there.
Rename Method re-factoring not only rename the variables but anywhere including comments (it can not be sure if string in comments is really variable name).
For example:
class ABC{
private String username;
private void X(){
String str = "username";
}
}
Now, after renaming the class member username, Android Studio will Behave like:
class ABC{
private String mUsername;
private void X(){
String str = "mUsername"; // it should be remain same as String str = "username";
}
}
Is there any way to change the Re-factoring Setting in Android Studio?
After a struggle, i got the solution.
During re-factoring/renaming the variable/member, it will display a popup. In this popup, you will see a sentence
"Press Shift+F6 to show dialog with more options"
Now if you will press "Shift+F6", a dialog will open for Re-factor-Setting.
Here, un-check "Search in comments and strings" .. Thats it..
Thanks for replies..
Taken from the link here:
Renaming of packages, classes, methods, fields, method parameters and
local variables with reference correction
The renaming functionality
allows you to rename any package, class, method or variable and
automatically finds and corrects all references to it. Before
renaming, you can preview all references in a convenient tree-view,
where you have an opportunity to select usages/references to be
renamed. For any item being refactored, it is also possible to search
for its name occurrences in strings and comments, so that the
commented code is also changed and kept up-to-date. The Rename
refactoring can be invoked from any view (Project, Source, Commander
and Structure), as well as directly from the editor.
In my version of Android Studio (2.2 RC 2) when I highlight a variable, right click and choose :
Refactor > Rename
this option pops up, then you can edit the rating text to whatever you want :
Rename code occurrences : it renames all usages of the variable named rating, throughout my project.
Rename all ocurrences : it renames the word rating (code, comments etc) throughout my project.
This question already has answers here:
mysqli bind_param() expected to be a reference, value given
(3 answers)
Closed 12 months ago.
Ok, this is a weird problem, so please bear with me as I explain.
We upgraded our dev servers from PHP 5.2.5 to 5.3.1.
Loading up our code after the switch, we start getting errors like:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /home/spot/trunk/system/core/Database.class.php on line 105
the line mentioned (105) is as follows:
call_user_func_array(Array($stmt, 'bind_param'), $passArray);
we changed the line to the following:
call_user_func_array(Array($stmt, 'bind_param'), &$passArray);
at this point (because allow_call_time_pass_reference) is turned off, php throws this:
Deprecated: Call-time pass-by-reference has been deprecated in /home/spot/trunk/system/core/Database.class.php on line 105
After trying to fix this for some time, I broke down and set allow_call_time_pass_reference to on.
That got rid of the Deprecated warning, but now the Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference warning is throwing every time, with or without the referencing.
I have zero clue how to fix this. If the target method was my own, I would just reference the incoming vars in the func declaration, but it's a (relatively) native method (mysqli).
Has anyone experienced this? How can I get around it?
Thank you.
I just experienced this same problem, calling bind_param via call_user_func_array and passing an array of parameters. The solution is to modify the values in the array to be referenced. It's not elegant but it works.
call_user_func_array(array($stmt, 'bind_param'), makeValuesReferenced($passArray));
function makeValuesReferenced($arr){
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
You are passing an array of elements ($passArray). The second item inside the passed array needs to be a reference, since that is really the list of items you are passing to the function.
Actually, be aware that there is a bug with PHP 5.3.1 concerning references and all call family of functions:
PHP Bugs #50394: Reference argument converted to value in __call
The behavior you are seeing might be a result of this bug and any attempt to fix it code wise may cause problems in the long run.
The problem has been fixed in the SVN version of PHP. Until 5.3.2 is released, you may compile a new version for use, or downgrade to an earlier version.
We were experiencing this same problem with this code:
call_user_func(array($strCartHandler, 'CartPurchaseEvent'), $strCartEvent, $objToUser, null, $this);
My solution was to just skip call_user_func altogether and do this:
$strCartHandler::CartPurchaseEvent($strCartEvent, $objToUser, null, $this);
I think what is deprecated is passing a reference through a function. In the function definition you do something like:
function(&$arg) {
}
This doesn't help you much but you probably need not pass the reference anyway. I guess you could try a wrapper function.
function wrapper($stmt, &$passArray) {
call_user_func_array($stmt, $passArray);
}
I think the mysqli_bind_param() and mysqli_bind_result() functions are very awkward to use. I've encountered the same difficulty as you describe using them in combination with call_user_func_array()
My workaround was to stop using mysqli and instead use PDO_mysql. It has a much easier usage:
$pdoStmt->execute( $passArray );
This will helps:
<?php
call_user_func_array(Array($stmt, 'bind_param'), array(&$passArray));
function bind_param ($val)
{
$val = (is_array($val)) ? $val[0] : $val;
// operations...
}
?>
The second paramer Must be an array. apparently this was only enforced in 5.3
I've got a similar problem, the current code didnt work:
$query="Select id,name FROM mytable LIMIT ?,?";
$params=Array('ii');
array_push($params,$from_var);
array_push($params,$to_var);
...
$stmt=$link->prepare("$query");
$ref=new ReflectionClass('mysqli_stmt');
$method=$ref->getMethod("bind_param");
$method->invokeArgs($stmt,$params);
...
It told that "Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given"
And then, in despair, I've tried to take $from_var and $to_var in quotes. And it worked!
$params=Array('ii');
array_push($params,"$from_var");
array_push($params,"$to_var");
Hope, it will help somebody, good luck :)