Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condition in switch case is ignored during compilation #63

Open
serjek opened this issue Aug 1, 2024 · 0 comments
Open

Condition in switch case is ignored during compilation #63

serjek opened this issue Aug 1, 2024 · 0 comments

Comments

@serjek
Copy link

serjek commented Aug 1, 2024

Consider following example:

@:attr var value:Option<Int>;

function render()
<View>
	<switch $value>
		<case ${Some(v) if (v > 0)}><Text>some $v</Text>
		<case $None><Text>none</Text>
	</switch>
</View>;

There are 2 problems here:

  • it compiles. Instead of this it should be requiring to handle Some(x) case
  • when compiled there is no condition if (v > 0) anymore:
__coco_render: function() {
  var _g = tink_state_Observable.get_value(this.__coco_value);
  var children;
  switch(_g._hx_index) {
  case 0:
	  var v = _g.v;
	  var __r = [];
	  __r.push("some ");
	  __r.push(v);
	  var cls = react_native_component_Text;
	  var children1 = [cls.__jsxStatic != null ? cls.__jsxStatic : cls,{ }].concat(__r);
	  children = React.createElement.apply(React,children1);
	  break;
  case 1:
	  var cls = react_native_component_Text;
	  var children1 = [cls.__jsxStatic != null ? cls.__jsxStatic : cls,{ }].concat(["none"]);
	  children = React.createElement.apply(React,children1);
	  break;
  }
  var cls = react_native_component_View;
  var tmp = [cls.__jsxStatic != null ? cls.__jsxStatic : cls,{ }].concat([children]);
  return React.createElement.apply(React,tmp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant